'Failed at the @angular/[email protected] postinstall script
Hi I can't install the angular cli with npm install -g @angular/[email protected].
I keep getting this :
> node ./bin/postinstall/script.js
module.js:549
throw err;
^
Error: Cannot find module '/root/.nvm/versions/node/v13.0.1/lib/node_modules/@angular/cli/bin/postinstall/script.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @angular/[email protected] postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @angular/[email protected] postinstall 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! /root/.npm/_logs/2019-11-26T00_10_33_515Z-debug.log
Node version : 13.0.1
Npm version : 6.13.1
Ubuntu version : 18.04.2
I also tried without specifying a CLI version.
Solution 1:[1]
I tried with this command that I found online :
npm install -g @angular/[email protected] --unsafe-perm=true --allow-root
And it worked.
Solution 2:[2]
Try to run with sudo npm. On Ubuntu, you need to run with root permission. It depends on how you install node.
sudo npm install -g @angular/[email protected]
On the other hand, try to install node 12 and LTS versions to have a more secure version.
Hope it helps
Solution 3:[3]
Steps I followed
- Downgrade node version using nvm to v12.3.0
- Remove
ngfolder from/root/.nvm/versions/node/v12.3.0/bin - Again do
npm install -g @angular/[email protected] --unsafe-perm=true --allow-root
and it worked
Solution 4:[4]
Try clean your npm cache before npm cache clean or npm cache verify then npm install -g @angular/[email protected] --unsafe-perm=true --allow-root
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Antoine OLIVIER |
| Solution 2 | Javier GarcĂa |
| Solution 3 | sudarshan |
| Solution 4 | Moise Scalzo |
