What is the difference between “npm update -g”, “npm upgrade -g”, “npm install -g npm”, and “n stable”?

前端 未结 1 506
庸人自扰
庸人自扰 2021-02-13 09:42

My npm seems out of date, so it seems I could use 4 ways to update it:

sudo npm update -g          # => npm 3.8.6
sudo npm upgrade -g         # => npm 3.8.         


        
相关标签:
1条回答
  • 2021-02-13 10:31

    What those commands do:

    1. sudo npm update -g - this command updates all installed global packages to the the latest versions.
    2. sudo npm upgrade -g - it's an alias for update command.
    3. sudo npm install -g npm - installs the latest available version of npm package.
    4. sudo npm cache clean -f && sudo npm install -g n && sudo n stable - cleans the npm cache, installs n (node version manager) and the latest available node.js and npm.

    So, if you need update npm to the latest version only, use sudo npm install -g npm, if you want to update and node and npm, use sudo npm cache clean -f && sudo npm install -g n && sudo n stable.

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