sudo: npm: command not found

前端 未结 25 2710
渐次进展
渐次进展 2020-11-28 01:19

I\'m trying to upgrade to the latest version of node. I\'m following the instructions at http://davidwalsh.name/upgrade-nodejs

But when I do:

sudo np         


        
25条回答
  •  情话喂你
    2020-11-28 02:00

    Work for me Resolving EACCES permissions errors when installing packages globally

    To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use hidden directory in your home directory.

    Back up your computer. On the command line, in your home directory, create a directory for global installations:

     mkdir ~/.npm-global
    

    Configure npm to use the new directory path:

     npm config set prefix '~/.npm-global'
    

    In your preferred text editor, open or create a ~/.profile file and add this line:

     export PATH=~/.npm-global/bin:$PATH
    

    On the command line, update your system variables:

     source ~/.profile
    

    To test your new configuration, install a package globally without using sudo:

     npm install -g jshint
    

提交回复
热议问题