I have git dependencies in my package.json file. When I do sudo npm install in my react app folder, I get this error
npm ERR! code 1
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
The answer worked for me. Recommend using find
and/or sudo find
to remove any .npm folder.
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