“npm update -g"、“npm upgrade -g"、“npm install -g npm"和“n stable"之间有什么区别? [英] What is the difference between "npm update -g", "npm upgrade -g", "npm install -g npm", and "n stable"?

查看:618
本文介绍了“npm update -g"、“npm upgrade -g"、“npm install -g npm"和“n stable"之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 npm 似乎过时了,所以我可以使用四种不同的方式来更新它:

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

sudo npm update -g          # => npm 3.8.6
sudo npm upgrade -g         # => npm 3.8.7
sudo npm install -g npm
sudo npm cache clean -f && sudo npm install -g n && sudo n stable

上面的一些方法安装了npm 3.8.6,一些安装了3.8.7,最后一个通过n安装了3.8.3.

Some of the methods above installed npm 3.8.6, some installed 3.8.7, and the last one by n installed 3.8.3.

这些方法之间有什么区别,是否有标准方法/官方方法来实现?

What are the differences between these methods and is there a standard way / official way to do it?

(3.8.6 和 3.8.7 的区别在于我的 MacBook 12 英寸 Retina 和 Mac OS Xv10.11 (El Capitan).我的 MacBook Pro 与 Mac 操作系统不同X v10.9(小牛队).

(The 3.8.6 and 3.8.7 difference was on my MacBook 12 inch Retina with Mac OS X v10.11 (El Capitan). It wasn't so on my MacBook Pro with Mac OS X v10.9 (Mavericks).)

推荐答案

这些命令的作用:

  1. sudo npm update -g - 此命令将所有已安装的全局包更新为最新版本.
  2. sudo npm upgrade -g - 它是 update 命令的别名.
  3. sudo npm install -g npm - 安装最新版本的 npm 包.
  4. sudo npm cache clean -f &&须藤 npm install -g n &&sudo n stable - 清理 npm 缓存,安装 n(节点版本管理器)和最新可用的 node.js 和 npm.
  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.

所以,如果你只需要更新npm到最新版本,使用sudo npm install -g npm,如果你想更新node和npm,使用<代码>sudo npm cache clean -f &&须藤 npm install -g n &&sudo n 稳定.

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.

这篇关于“npm update -g"、“npm upgrade -g"、“npm install -g npm"和“n stable"之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆