'npm install and npm i -g @angular/cli commands failing with command failed error

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source