Permission denied for Git Clone when I do npm install

后端 未结 4 636
南笙
南笙 2020-12-14 22:49

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
           


        
相关标签:
4条回答
  • 2020-12-14 23:27

    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
    
    0 讨论(0)
  • 2020-12-14 23:37

    The answer worked for me. Recommend using find and/or sudo find to remove any .npm folder.

    0 讨论(0)
  • 2020-12-14 23:45

    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.

    0 讨论(0)
  • 2020-12-14 23:45

    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
    
    0 讨论(0)
提交回复
热议问题