npm 更新本地包

我们先在项目里面安装一个包vue,版本是2.3.1

npm install vue@2.3.1 --save

 

1. 查看包的版本

可以使用 npm info 这个命令查看包的版本。

npm info vue

输出结果如下:

vue@2.5.16 | MIT | deps: none | versions: 229
Reactive, component-oriented view layer for modern web interfaces.
https://github.com/vuejs/vue#readme

dist
.tarball http://registry.npm.taobao.org/vue/download/vue-2.5.16.tgz
.shasum: 07edb75e8412aaeed871ebafa99f4672584a0085

maintainers:
- yyx990803 <yyx990803@gmail.com>

dist-tags:
beta: 2.5.17-beta.0  csp: 1.0.28-csp      latest: 2.5.16

published 2 months ago by yyx990803 <yyx990803@gmail.com>

 

2. 检查更新包

检查更新可以使用 npm outdated,例如:

npm outdated vue

输入如下:

Package  Current  Wanted  Latest  Location
vue        2.3.1  2.5.16  2.5.16  xxkt

表示,当前版本是:2.3.1,可以更新到的版本是:2.5.16,最新版本是:2.5.16

 

3. 执行更新

想要去执行一下更新,可以使用 npm update 这个命令。

npm update

输出如下:

+ vue@2.5.16
updated 1 package in 2.628s

表示vue已经更新到了2.5.16