assuming that all your other issues have been resolved by reading comments, I will focus on the MongoDB part...
let's use some common variable names and functions widely used in the community to demonstrate...
such as mainWindow
or createWindow
...
if you want to execute mongodb
from electron, you can utilize child_process.execFile
to spawn a non-blocking process from electron..
you can run it either before or after the createWindow
function...
for running it before, execute it directly from the main process and utilize the stdout
and stderr
of child_process
for potential outcomes...
if you wish to run it after createWindow
, then send a signal to trigger it from mainWindow
through ipcRenderer
or any other method you prefer...
here is an example of the code -
const { execFile } = require('child_process')
let mongoDbCP = execFile('path_to_mongod_file, ['--dabpath=path_to_db', 'any_other_args], { 'any_options': 'if_you_want_to_pass_for_child_process' }, (error) => { \* handle error *\ })
mongoDbCP.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
on windows
, when you quit your app, mongod
will also exit automatically...
however, on macos
, you need to manually terminate it before quitting using killall [process_name]
or kill -9 [process_pid]
explicitly ..