简体   繁体   中英

Uncaught Error: spawn .\node.exe ENOENT

I have a nodejs app being run through electron

https://github.com/frankhale/electron-with-express

After packaging the app as an executable using npm run dist:win32 , I ran into the following issue in console:

events.js:160 Uncaught Error: spawn .\node.exe ENOENT

Below is how my devDependencies looks like

"devDependencies": {
    "electron-builder": "^5.26.0",
    "electron-prebuilt": "^1.3.3",
    "electron-rebuild": "^1.2.0"
  }

When i run the app using npm start it works fine, and no error is run. Its when the app is run as an executable i see the error on console.

I had the same problem, after many try/search, I found a solution. Use 'fix-path'.

https://www.npmjs.com/package/fix-path

npm install --save fix-path

Then, use it like this before your spawn :

// Use to access 'spawn' when the app is packaged
const fixPath = require('fix-path')();
// or
const fixPath = require('fix-path');
fixPath();

low rep here or else I would just comment. Thanks for sharing your repo. I used a combo of your solution and this workaround to get processes spawned from inside packaged .app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM