Developers Notes

My Journey as Software Architect

npm install Access Denied

If you face this issue

Unhandled rejection Error: EACCES: permission denied, open '/home/ubuntu/.npm/_cacache/index-v5/04/82/83016d88317bc219a7ecb0d1ef655bed9bb26a45696ad38e2590e0486bef'

Unhandled rejection Error: EACCES: permission denied, open '/home/ubuntu/.npm/_cacache/index-v5/e2/46/4705c8c8600a93ac62b3b76debefa2d25956d07b3d181cd758e49cfffda8'

 

you can fix it by restore ownership using this command

 

sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config

or

sudo chown -R $(whoami) ~/.npm

another method that work

sudo npm install --unsafe-perm=true --allow-root

and this

sudo npm cache clean --force --unsafe-perm

If you have issue on install package without sudo, run this

sudo chown -R $(whoami) /usr/local/lib/node_modules

 

Another solutions

docs.npmjs.com

 

you can see clear explaination from

stackoverflow.com