我安装了最新版本的节点和电子并试用了样品。当我进入" npm start"时,它们会工作。 但是:当我尝试在另一个文件夹中创建应用程序并启动它时,我得到这个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%正常,我该怎么办?再安装一次?如何正确卸载? - 我被困了,请帮忙; - )
答案 0 :(得分:1)
技术性在您的package.json和您的Electron安装中,但无论是否将其保存在dependencies
下。
如果package.json中的start
脚本调用electron .
,则需要使用npm install electron -g
全局安装Electron。这适用于您使用名称的所有命令,非常类似于mocha
和cordova create
。只是一些例子。
要在本地(非全局)使用它,并且只在项目内部使用,您只需调用npm install electron
(您可能已经完成),但您的start
脚本必须指向{ {1}}文件位于本地electron
文件夹中。通常路径为node_modules
,您的起始脚本可能看起来像node_modules/.bin/electron.cmd
如果您在IDE中遇到此问题,则应将node_modules/.bin/electron .
中的electron.cmd
设置为可执行文件,然后将.bin
设置为您的参数。 < / p>
答案 1 :(得分:0)
确保您已全局安装electron
,为此请运行以下命令:
npm install -g electron
安装完成后,尝试在命令提示符下运行electron
,它应该打开一个演示应用程序。
要从全局范围卸载电子:
npm uninstall -g electron