Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 351
Antoine OLIVIER Avatar asked Nov 26 '19 00:11

Antoine OLIVIER


3 Answers

I tried with this command that I found online :

npm install -g @angular/[email protected] --unsafe-perm=true --allow-root

And it worked.

like image 120
Antoine OLIVIER Avatar answered Oct 18 '22 21:10

Antoine OLIVIER


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

like image 35
Javier García Avatar answered Oct 18 '22 21:10

Javier García


Steps I followed

  1. Downgrade node version using nvm to v12.3.0
  2. Remove ng folder from /root/.nvm/versions/node/v12.3.0/bin
  3. Again do npm install -g @angular/[email protected] --unsafe-perm=true --allow-root

and it worked

like image 1
Sudarshan Avatar answered Oct 18 '22 20:10

Sudarshan