Home > Blockchain >  sh: 1: node: Permission denied, install angular on WSL
sh: 1: node: Permission denied, install angular on WSL

Time:01-19

I try to install angular on WSL2, I have node version 17.3.1 and npm version 8.3.0 installed. When I type the command npm install -g @angular/cli I get this error:

npm ERR! code 127

npm ERR! path /root/.nvm/versions/node/v17.3.1/lib/node_modules/@angular/cli

npm ERR! command failed

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

npm ERR! sh: 1: node: Permission denied

npm ERR! A complete log of this run can be found in:

npm ERR! /root/.npm/_logs/2022-01-18T09_06_05_078Z-debug-0.log

Any suggestion?

CodePudding user response:

Try to run with sudo npm. On Ubuntu, you need to run with root permission. It depends on how you install node.

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

CodePudding user response:

@Mario Petrovic:

Didnt work:

➜ npm cache verify

Cache verified and compressed (~/.npm/_cacache)

Content verified: 810 (23733249 bytes)

Index entries: 810

Finished in 3.679s


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

npm ERR! code 127

npm ERR! path/root/.nvm/versions/node/v17.4.0/lib/node_modules/@angular/cli

npm ERR! command failed

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

npm ERR! sh: 1: node: Permission denied

npm ERR! A complete log of this run can be found in:

npm ERR!     /root/.npm/_logs/2022-01-19T11_42_03_287Z-debug-0.log
  •  Tags:  
  • Related