sudo: npm: command not found

前端 未结 25 2658
渐次进展
渐次进展 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 01:57

    For debian after installing node enter

    curl -k -O -L https://npmjs.org/install.sh    
    ln -s /usr/bin/nodejs /usr/bin/node  
    sh install.sh
    
    0 讨论(0)
  • 2020-11-28 01:59

    If you have downloaded node package and extracted somewhere like /opt you can simply create symbolic link inside /usr/local/bin.

    /usr/local/bin/npm -> /opt/node-v4.6.0-linux-x64/bin/npm
    /usr/local/bin/node -> /opt/node-v4.6.0-linux-x64/bin/node
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2020-11-28 02:00

    Appended npm binary path to sudo path using visudo and editing "secure_path"

    Now "sudo npm" works

    0 讨论(0)
  • 2020-11-28 02:02

    simply reinstall .

    On RHEL, CentOS and Fedora

    sudo yum remove nodejs npm
    sudo dnf remove nodejs npm   [On Fedora 22+ versions]
    

    then

    yum -y install nodejs npm
    dnf -y install nodejs npm   [On Fedora 22+ versions]
    

    easy!.. both node and npm works like a charm now!

    0 讨论(0)
  • 2020-11-28 02:03

    For MAC users, the follow steps worked for me.

    If you get Error for Brew, Here's the command you need to type first in the terminal:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    

    Then run following commands:
    $ brew update
    $ brew uninstall node
    $ brew install node
    $ brew postinstall 
    
    0 讨论(0)
提交回复
热议问题