sudo: npm: command not found

前端 未结 25 2655
渐次进展
渐次进展 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:44

    If you installed node/npm with nvm, the nvm environment configuration file has to be run before you can use either package.

    This is generally found in ~/.nvm/nvm.sh.

    To run this automatically, include:

    source ~/.nvm/nvm.sh
    

    in the .bash_profile file for your user

    If you then want to use sudo with that user, make sure to include the -i parameter to make sudo set the user environment. eg

    sudo -iu jenkins npm install grunt-cli
    
    0 讨论(0)
  • 2020-11-28 01:44

    Installl node.js & simply run

    npm install -g bower 
    

    from your project dir

    0 讨论(0)
  • 2020-11-28 01:45

    I had the same issue,the reason for it was npm package manager was not installed while installing node. This was caused because of the following mistake: In the installation process there is a step called "Custom Setup", here you have the option to choose one of the following: 1) Node.js runtime (This is selected by default). 2) npm package manager 3) Online documentation shortcuts. 4) Add to Path. If you proceed as it is npm package manager will not be installed and hence you will get the error.

    Solution: Select npm package manager when you get these options. This worked for me.

    0 讨论(0)
  • 2020-11-28 01:45

    Remove Node completely:

      brew uninstall --force node
    

    Install again:

    brew install node;
    which node # => /usr/local/bin/node
    export NODE_PATH='/usr/local/lib/node_modules'
    
    0 讨论(0)
  • 2020-11-28 01:46

    I had to do

    sudo apt-get install npm
    

    that worked for me.

    0 讨论(0)
  • 2020-11-28 01:46

    On macOS, this worked for me:

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