NPM permission error while installing

前端 未结 4 1315
别那么骄傲
别那么骄傲 2021-01-14 09:19

i am trying to install yeoman on my server but for some reason do i keep getting a permission denied error.

$npm install -g yo
/root/.node/bin/yo -> /root         


        
相关标签:
4条回答
  • 2021-01-14 09:30

    To avoid permission errors, install node with nvm.

    See the detailed solution here: npm install g less does not work

    0 讨论(0)
  • 2021-01-14 09:34

    I had the same issue and tried running the install using 'sudo npm install -g yo' but it still failed. I couldn't get away from the fact that the error message still said 'sh: 1: yodoctor: Permission denied', indicating a permissions issue. I therefore tried completely changing to the root user using 'sudo su' and THEN running 'npm install -g yo'. This worked for me.

    If, like me, when running the install that way you encounter other errors, it could be because you need to upgrade npm first (run 'npm install -g npm' to do that). It could also be because you have yo partially installed from your previous attempts and that's causing issues. Therefore you can try removing it first using 'npm remove -g yo' (still as root user) and then installing it again using 'npm install -g yo'.

    Hope this helps someone out there.

    0 讨论(0)
  • I think Shantaru is right, you need to do it with sudo.

    Try this

    sudo npm uninstall -g yo
    sudo npm cache clean
    sudo npm install -g yo
    

    I have a similar problem weeks ago and that works.

    Edit: If that didn't work, do this before:

    npm config set unsafe-perm true
    
    0 讨论(0)
  • 2021-01-14 09:49

    You need to have root permission to install this so try "sudo npm install -g yo" instead of "npm install -g yo"

    0 讨论(0)
提交回复
热议问题