Permission denied for Git Clone when I do npm install

后端 未结 4 674
南笙
南笙 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 
    npm cache clean
    rm -rf node_modules
    npm install
    

提交回复
热议问题