admin管理员组文章数量:1389903
I have build an node.js, express.js app, electron app and in operating system Windows. I have packaged the electron app through the tutorial: How to package an electron app
The packaging to win32 is successful without any warning or errors.
However when I try to run the app.exe file from the dist folder, though the main application window shows up but I cannot see any content that I have in my express.js app folder.
My app folder structure is:
app-root<br>
- express-app
- bin
- www
- node_modules
- public
- routes
- views
- app.js
- package.json
- node_modules
- build
- index.html
- main.js
- package.json
- start-electron.js
- dist<br>
Now The node.js, express.js app in electron runs smoothly normally before packaging. The app does not run from the exe file after packaging.
This is the error in console for the package .exe file:
events.js:163 Uncaught Error: spawn node ENOENT
at exports._errnoException (util.js:1050:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _binedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
I have the SPAWN function in the index.html as:
spawn = require("child_process").spawn,
app = require('electron').remote.app,
node = spawn("node", ["./express-app/bin/www"], {
cwd: app.getAppPath()
})
Any kind of help will be appreciated.
I have build an node.js, express.js app, electron app and in operating system Windows. I have packaged the electron app through the tutorial: How to package an electron app
The packaging to win32 is successful without any warning or errors.
However when I try to run the app.exe file from the dist folder, though the main application window shows up but I cannot see any content that I have in my express.js app folder.
My app folder structure is:
app-root<br>
- express-app
- bin
- www
- node_modules
- public
- routes
- views
- app.js
- package.json
- node_modules
- build
- index.html
- main.js
- package.json
- start-electron.js
- dist<br>
Now The node.js, express.js app in electron runs smoothly normally before packaging. The app does not run from the exe file after packaging.
This is the error in console for the package .exe file:
events.js:163 Uncaught Error: spawn node ENOENT
at exports._errnoException (util.js:1050:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _binedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
I have the SPAWN function in the index.html as:
spawn = require("child_process").spawn,
app = require('electron').remote.app,
node = spawn("node", ["./express-app/bin/www"], {
cwd: app.getAppPath()
})
Any kind of help will be appreciated.
Share Improve this question edited Aug 14, 2017 at 8:33 echology asked Aug 14, 2017 at 6:04 echologyechology 3972 gold badges3 silver badges15 bronze badges2 Answers
Reset to default 1I have found a solution that does not require SPAWN, in an application with Node.js, Express.js and Electron. And works perfectly well even after packaging the electron app.
Here is the link to its GitHub repository:
GitHub repository for the solution's boilerplate.
One thing to remember is that after packaging the electron app through third party packagers like electron-builder it is necessary to put the config.json file into the new distribution/dist folder where the packaged files are present otherwise it throws the config.json not found error on the application execution.
You can use the following code using exec :
const exec = require('child_process').exec;
const node = exec("path/to/node " + app.getAppPath() + 'YOUR_APP', (err, stdout) => {console.log(stdout)});
path/to/node in my case => /usr/local/bin/node
It works perfectly
本文标签: javascriptSPAWN node ENOENT error in electron package on runStack Overflow
版权声明:本文标题:javascript - SPAWN node ENOENT error in electron package on run - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744654271a2617870.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论