未捕获的错误:spawn . ode.exe ENOENT [英] Uncaught Error: spawn . ode.exe ENOENT
问题描述
我有一个通过 electron 运行的 nodejs 应用程序
I have a nodejs app being run through electron
https://github.com/frankhale/electron-with-express
使用 npm run dist:win32
将应用程序打包为可执行文件后,我在控制台中遇到了以下问题:
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 .
ode.exe ENOENT
下面是我的 devDependencies 的样子
Below is how my devDependencies looks like
"devDependencies": {
"electron-builder": "^5.26.0",
"electron-prebuilt": "^1.3.3",
"electron-rebuild": "^1.2.0"
}
当我使用 npm start 运行应用程序时,它运行良好,并且没有运行错误.当应用程序作为可执行文件运行时,我在控制台上看到了错误.
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();
这篇关于未捕获的错误:spawn . ode.exe ENOENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!