运行npm,npm运行或npm运行-脚本在npm ERR! errno 3221225781中失败
我的节点是干净地安装了稳定版本的10.16.3 LTS,在Windows 10上安装了npm 6.9.0,所有的东西都安装在C:上的默认路径上。
我的示例是使用当前文件结构的最小设置:
node_modules/ <empty>
index.js
package.jsonnode_modules文件夹为空。
index.js:
console.log("Hello world..");package.json:
{
"name": "testnpm",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
}
}运行npm启动
H:\dev\javascript\testnpm>npm start
> testnpm@1.0.0 start H:\dev\javascript\testnpm
> node index.js
npm ERR! code ELIFECYCLE
npm ERR! errno 3221225781
npm ERR! testnpm@1.0.0 start: `node index.js`
npm ERR! Exit status 3221225781
npm ERR!
npm ERR! Failed at the testnpm@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! <Path to logs>\_logs\2019-10-19T13_24_15_158Z-debug.log预期的输出将是"Hello .“但如上面所示失败了。
直接运行相同的命令将得到预期的结果:
H:\dev\javascript\testnpm>node index.js
Hello world..以下是失败后的日志:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle testnpm@1.0.0~prestart: testnpm@1.0.0
6 info lifecycle testnpm@1.0.0~start: testnpm@1.0.0
7 verbose lifecycle testnpm@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle testnpm@1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;H:\dev\javascript\testnpm\node_modules\.bin;...
9 verbose lifecycle testnpm@1.0.0~start: CWD: H:\dev\javascript\testnpm
10 silly lifecycle testnpm@1.0.0~start: Args: [ '-c', 'node index.js' ]
11 silly lifecycle testnpm@1.0.0~start: Returned: code: 3221225781 signal: null
12 info lifecycle testnpm@1.0.0~start: Failed to exec start script
13 verbose stack Error: testnpm@1.0.0 start: `node index.js`
13 verbose stack Exit status 3221225781
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid testnpm@1.0.0
15 verbose cwd H:\dev\javascript\testnpm
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v10.16.3
19 verbose npm v6.9.0
20 error code ELIFECYCLE
21 error errno 3221225781
22 error testnpm@1.0.0 start: `node index.js`
22 error Exit status 3221225781
23 error Failed at the testnpm@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 3221225781, true ]要明确的是,npm install和类似的工作。用node启动脚本也很好。唯一不起作用的是在package.json中使用npm运行任何定义的脚本。
====================================
编辑:
在用npm i -g npm
chocolatey,然后安装以下的chocolatey - chocolatey-dotnetfx.extension v1.0.1
- python2 v2.7.17
- kb3033929 v1.0.5
- visualstudio2017buildtools v15.9.17.0
- chocolatey-windowsupdate.extension v1.0.4
- vcredist140 v14.23.27820
- kb2999226 v1.0.20181019
- visualstudio-installer v2.0.1
- kb2919355 v1.0.20160915
- chocolatey-core.extension v1.3.3
- kb2919442 v1.0.20160915
- visualstudio2017-workload-vctools v1.3.2
- chocolatey-visualstudio.extension v1.8.1
- dotnetfx v4.8.0.20190930
- kb3035131 v1.0.3发布于 2019-10-19 14:01:13
原语回答
看起来这是一个npm的依赖关系的问题。
运行npm i -g npm并再试一次。它应该能解决你的问题。
编辑
我做了些调查。我主要是在linux上使用节点,所以没有意识到这一点。在Windows上,您需要安装VC++再发行版。
您可以从https://www.microsoft.com/en-us/download/details.aspx?id=48145下载
来源:https://github.com/electron/electron-quick-start/issues/55
发布于 2019-10-19 14:42:05
尝试npm cache clean,我知道node_modules目录是空的,但是为了安全起见,只需删除它。您还应该删除package-lock.json文件。然后运行npm install。
https://stackoverflow.com/questions/58464223
复制相似问题