Unable to build with electron-packager within electron-forge

喜你入骨 提交于 2021-02-08 20:38:22

问题


I have created a default project with electron-forge. When I try to package my project with the command electron-forge, the process exits with the following error.

What am I doing wrong? I followed the instructions to a tee at electron-forge.

$ electron-forge package
✔ Checking your system
✔ Preparing to Package Application for arch: x64
✔ Compiling Application
✔ Preparing native dependencies
⠦ Packaging Application
An unhandled rejection has occurred inside Forge:
Command failed: npm prune --production
npm WARN electron-example@1.0.0 No repository field.

npm ERR! May not delete: /tmp/electron-packager/linux-x64/electron-example-linux-x64/resources/app/node_modules/.bin

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/maxchehab/.npm/_logs/2017-07-21T04_40_37_618Z-debug.log

Error: Command failed: npm prune --production
npm WARN electron-example@1.0.0 No repository field.

npm ERR! May not delete: /tmp/electron-packager/linux-x64/electron-example-linux-x64/resources/app/node_modules/.bin

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/maxchehab/.npm/_logs/2017-07-21T04_40_37_618Z-debug.log

    at ChildProcess.exithandler (child_process.js:270:12)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:921:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

Thank you for your time.


回答1:


Problem is solved in later versions of npm, please consider upgrading to the latest v ( > 5.4.2) instead of downgrading to 5.2:

npm i -g npm



回答2:


It looks like the latest version of npm has introduced a bug for the electron make process. Issue is being tracked here. Github Issue

Try this workaround for a possible fix(untested):

rm -rf node_modules
npm install --production --ignore-scripts
npm install --no-save electron-rebuild --ignore-scripts
node_modules/.bin/electron-rebuild
npm remove electron-rebuild --ignore-scripts

Or downgrade your npm to a version less than 5.3(tested, works).

npm i -g npm@5.2


来源:https://stackoverflow.com/questions/45229218/unable-to-build-with-electron-packager-within-electron-forge

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