Permission denied for Git Clone when I do npm install

我与影子孤独终老i 提交于 2019-11-28 21:39:05

I had this exact same error with installing chimp (not from a git repo) after I'd upgraded from NodeJS 6.10 to 8.10 (and more importantly, to NPM 5.6.0). The problem is that npm 5 handles permissions / directories very differently than npm 4.

The solution is to NEVER use sudo when running npm 5. You'll find cases of when you have to use it with npm 4, but you shouldn't need to use sudo with npm 5. If you're installing globally, this link might help you. It didn't help me.

Since I was in a docker container, I could just modify my docker file to not use sudo and then everything was fine. If you're not, I suggest you run the following as your user (not root):

cd ~
sudo rm -rf .npm
cd <wherever your package.json/node_modules is>
npm cache clean
rm -rf node_modules
npm install

I don't know whether your problem is solved or not. Today i faced the same issue the problem was ~/.npm folder is messing with permission so I changed permission as sudo chown -R $(whoami) ~/.npm and it is working fine.

This is not a proper fix (DON'T DO IT), but it worked for me. Go to superuser mode and then do npm install with sudo.

sudo su
sudo npm install
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!