npm install 和 npm i -g @angular/cli 命令失败,出现命令失败错误

发布于 2025-01-10 18:34:18 字数 3400 浏览 0 评论 0原文

我克隆了一个角度存储库,运行 npm i 并抛出以下错误:

PS C:\projects\FIFA\skeleton> npm i 
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map- 
resolve#deprecated
npm ERR! code 3221225477
npm ERR! path C:\projects\FIFA\skeleton\node_modules\@angular\cli
npm ERR! command failed
npm ERR! command bash -c node ./bin/postinstall/script.js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\148965\AppData\Local\npm-cache\_logs\2022-03-01T03_54_05_112Z-debug-0.log

我运行了此命令 npm cache clean --force ,但仍然 npm i抛出同样的错误。

我将 nodejs16.13.0 升级到 16.14.0,但 npm i 仍然抛出相同的错误。

我卸载了 @angular/cli npm uninstall -g @angular/cli 并在重新安装时 npm i -g @angular/cli 面临同样的错误:

npm ERR! code 3221225477
npm ERR! path C:\Users\148965\AppData\Roaming\npm\node_modules\@angular\cli
npm ERR! command failed
npm ERR! command bash -c node ./bin/postinstall/script.js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\148965\AppData\Local\npm-cache\_logs\2022-03-01T04_19_25_333Z-debug-0.log

某些软件包正在安装,例如:npm i -g http-servernpm i -g lite-server

npm i -g nodemon面临同样的问题

< code>npm i 也可以正常工作在其他节点项目中。

问题仅存在于 Angular 中。

完整详细:

1014 verbose stack Error: command failed
1014 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
1014 verbose stack     at ChildProcess.emit (node:events:520:28)
1014 verbose stack     at maybeClose (node:internal/child_process:1092:16)
1014 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
1015 verbose pkgid @angular/[email protected]
1016 verbose cwd C:\projects\FIFA\examples
1017 verbose Windows_NT 10.0.19043
1018 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
1019 verbose node v16.14.0
1020 verbose npm  v8.3.1
1021 error code 3221225477
1022 error path C:\Users\148965\AppData\Roaming\npm\node_modules\@angular\cli
1023 error command failed
1024 error command bash -c node ./bin/postinstall/script.js
1025 verbose exit 3221225477
1026 timing npm Completed in 13130ms
1027 verbose unfinished npm timer reify 1646108365627
1028 verbose unfinished npm timer reify:build 1646108377372
1029 verbose unfinished npm timer build 1646108377373
1030 verbose unfinished npm timer build:deps 1646108377373
1031 verbose unfinished npm timer build:run:postinstall 1646108377399
1032 verbose unfinished npm timer build:run:postinstall:node_modules/@angular/cli 1646108377399
1033 verbose code 3221225477
1034 error A complete log of this run can be found in:
1034 error     C:\Users\148965\AppData\Local\npm-cache\_logs\2022-03-01T04_19_25_333Z-debug-0.log

节点版本:

npm -v
8.3.1

node -v
v16.14.0

我无法理解导致此问题的原因。 直到昨天一切都很好。

任何帮助表示赞赏。提前致谢。

I cloned an angular repository, ran npm i and it throws below error:

PS C:\projects\FIFA\skeleton> npm i 
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map- 
resolve#deprecated
npm ERR! code 3221225477
npm ERR! path C:\projects\FIFA\skeleton\node_modules\@angular\cli
npm ERR! command failed
npm ERR! command bash -c node ./bin/postinstall/script.js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\148965\AppData\Local\npm-cache\_logs\2022-03-01T03_54_05_112Z-debug-0.log

I ran this command npm cache clean --force and still npm i throws the same error.

I upgraded nodejs from 16.13.0 to 16.14.0 and still npm i throws the same error.

I uninstalled @angular/cli npm uninstall -g @angular/cli and when reinstalling it npm i -g @angular/cli facing the same error:

npm ERR! code 3221225477
npm ERR! path C:\Users\148965\AppData\Roaming\npm\node_modules\@angular\cli
npm ERR! command failed
npm ERR! command bash -c node ./bin/postinstall/script.js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\148965\AppData\Local\npm-cache\_logs\2022-03-01T04_19_25_333Z-debug-0.log

Some packages are getting installed, like: npm i -g http-server and npm i -g lite-server

Facing the same issue with npm i -g nodemon

npm i also works fine in other node projects.

Issue exists only in Angular.

Full verbose:

1014 verbose stack Error: command failed
1014 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
1014 verbose stack     at ChildProcess.emit (node:events:520:28)
1014 verbose stack     at maybeClose (node:internal/child_process:1092:16)
1014 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
1015 verbose pkgid @angular/[email protected]
1016 verbose cwd C:\projects\FIFA\examples
1017 verbose Windows_NT 10.0.19043
1018 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
1019 verbose node v16.14.0
1020 verbose npm  v8.3.1
1021 error code 3221225477
1022 error path C:\Users\148965\AppData\Roaming\npm\node_modules\@angular\cli
1023 error command failed
1024 error command bash -c node ./bin/postinstall/script.js
1025 verbose exit 3221225477
1026 timing npm Completed in 13130ms
1027 verbose unfinished npm timer reify 1646108365627
1028 verbose unfinished npm timer reify:build 1646108377372
1029 verbose unfinished npm timer build 1646108377373
1030 verbose unfinished npm timer build:deps 1646108377373
1031 verbose unfinished npm timer build:run:postinstall 1646108377399
1032 verbose unfinished npm timer build:run:postinstall:node_modules/@angular/cli 1646108377399
1033 verbose code 3221225477
1034 error A complete log of this run can be found in:
1034 error     C:\Users\148965\AppData\Local\npm-cache\_logs\2022-03-01T04_19_25_333Z-debug-0.log

Node versions:

npm -v
8.3.1

node -v
v16.14.0

I am unable to understand what is causing this issue.
Everything was fine till yesterday.

Any help is appretiated. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬 2025-01-17 18:34:18

错误行

npm ERR! command failed
npm ERR! command bash -c node ./bin/postinstall/script.js

表明执行 bash 命令(shell 脚本)时出现一些问题。

据我了解,当 npm 当前使用的 shell 损坏时,就会出现此错误。

以下命令重置 shell 以用于通过 npm exec、npm run 和 npm init 命令运行的脚本。

npm config 删除 script-shell

The error lines

npm ERR! command failed
npm ERR! command bash -c node ./bin/postinstall/script.js

suggest that there is some issue executing bash command (shell script).

From what I understand is, this error comes when the shell that is currently being used by npm is corrupted.

And the below command resets the shell to use for scripts run with the npm exec, npm run and npm init commands.

npm config delete script-shell

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文