电子作品,有点…?

我安装了最新版本的节点和电子,并尝试了样品。 当我input“npm start”时他们工作。 但是:当我尝试在另一个文件夹中创build一个应用程序并启动它时,我得到了这个npm-debug.log:

0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] 2 info using npm@3.10.10 3 info using node@v6.11.2 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle proton-template-app@1.0.0~prestart: proton-template-app@1.0.0 6 silly lifecycle proton-template-app@1.0.0~prestart: no script for prestart, continuing 7 info lifecycle proton-template-app@1.0.0~start: proton-template-app@1.0.0 8 verbose lifecycle proton-template-app@1.0.0~start: unsafe-perm in lifecycle true 9 verbose lifecycle proton-template-app@1.0.0~start: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/erik/Projects/Electron/tmp2/node_modules/.bin:/home/erik/bin:/home/erik/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin 10 verbose lifecycle proton-template-app@1.0.0~start: CWD: /home/erik/Projects/Electron/tmp2 11 silly lifecycle proton-template-app@1.0.0~start: Args: [ '-c', 'electron .' ] 12 info lifecycle proton-template-app@1.0.0~start: Failed to exec start script 13 verbose stack Error: proton-template-app@1.0.0 start: `electron .` 13 verbose stack spawn ENOENT 13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:33:16) 13 verbose stack at emitTwo (events.js:106:13) 13 verbose stack at ChildProcess.emit (events.js:191:7) 13 verbose stack at maybeClose (internal/child_process.js:891:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) 14 verbose pkgid proton-template-app@1.0.0 15 verbose cwd /home/erik/Projects/Electron/tmp2 16 error Linux 4.4.0-79-generic 17 error argv "/usr/bin/node" "/usr/bin/npm" "start" 18 error node v6.11.2 19 error npm v3.10.10 20 error file sh 21 error code ELIFECYCLE 22 error errno ENOENT 23 error syscall spawn 24 error proton-template-app@1.0.0 start: `electron .` 24 error spawn ENOENT 25 error Failed at the proton-template-app@1.0.0 start script 'electron .'. 25 error Make sure you have the latest version of node.js and npm installed. 25 error If you do, this is most likely a problem with the proton-template-app package, 25 error not with npm itself. 25 error Tell the author that this fails on your system: 25 error electron . 25 error You can get information on how to open an issue for this project with: 25 error npm bugs proton-template-app 25 error Or if that isn't available, you can get their info via: 25 error npm owner ls proton-template-app 25 error There is likely additional logging output above. 26 verbose exit [ 1, true ] 

恐怕我的安装不是100%好,我该怎么办? 再次安装? 如何正确卸载? – 我卡住了,请帮忙;-)

确保你已经在全球安装electron ,这样做运行以下命令:

npm install -g electron

一旦你安装了它,尝试在你的命令提示符运行electron应该打开一个演示程序。


从全球范围卸载电子: npm uninstall -g electron

技术性是在你的package.json和你的Electron的安装,但是这是不pipe在dependencies下保存。

如果你在package.json中的start脚本调用electron . ,您将需要使用npm install electron -g全局安装Electron。 这适用于所有使用名称的命令,就像mochacordova create 。 只是一些例子。

要在本地(非全局)使用它,只在项目内部使用,你可以调用npm install electron (你可能已经完成了),但是你的start脚本必须指向本地node_modules文件夹中的node_modules文件。 通常path是node_modules/.bin/electron.cmd ,你的启动脚本可能看起来像node_modules/.bin/electron .

如果您在IDE中遇到过这个问题,那么您应该将.bin中的electron.cmd设置为您的可执行文件. 作为你的论点。