I'm working on an electron app and within the app, I execute shell commands using child_process.exec
. One of the commands I run is npm run start
; this works perfectly in a dev environment but when I build the application for production all npm
commands fail with showing the following error:
Error: Command failed: npm run start
/bin/sh: npm: command not found
at ChildProcess.exithandler (child_process.js:287)
at emitTwo (events.js:126)
at ChildProcess.emit (events.js:214)
at maybeClose (internal/child_process.js:925)
at Socket.stream.socket.on (internal/child_process.js:346)
at emitOne (events.js:116)
at Socket.emit (events.js:211)
at Pipe._handle.close [as _onclose] (net.js:554)
I tried running the application in debug mode by running the following command open MyApp.app/Contents/MacOS/MyApp
and the npm
commands run successfully with no errors.
What could be the issue?