Uncaught Error: spawn .\node.exe ENOENT

2019-03-01 02:43发布

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.

2条回答
做自己的国王
2楼-- · 2019-03-01 03:11

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();
查看更多
叼着烟拽天下
3楼-- · 2019-03-01 03:33

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.

查看更多
登录 后发表回答