Oscar J. Irun
Oscar J. Irun

Reputation: 475

Atom Electron cant find path of child process?

I built an app with electron and in the root directory I have a library. I want to run a child process from my app, so I use it like this:

spawn(path.resolve(LIB_PATH +'command_to_run')

This works when I run the app with npm start. But if I use electron-packager to make a build, it seems that it doesn't find the command. I receive this error: enter image description here

Any ideas why this happens? I was researching a lot about it, but can't find anything.

Thanks

Upvotes: 1

Views: 461

Answers (1)

Oscar J. Irun
Oscar J. Irun

Reputation: 475

Found the solution. When I run npm start I can directly call ./command_to_run from the root of my project. But when I create a .app file, I need to add this: path.dirname(require.main.filename) + 'command_to_run'. Then it'll call the file that is in the root of my directory.

Upvotes: 1

Related Questions