Uncaught Error: spawn .\node.exe ENOENT

强颜欢笑 提交于 2019-12-02 10:40:03

问题


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.


回答1:


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();



回答2:


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.



来源:https://stackoverflow.com/questions/40798047/uncaught-error-spawn-node-exe-enoent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!