2

npm包版本

安装特定版本的包

npm install name@version
verson ---- [major, minor, patch]

查看工程安装的包版本号

npm ls --depth 深度

常用的版本表示方法

1.带x和*的版本表示法

npm install name@1.2.x ---- 1.2.0 <= verion < 1.3.0
npm install name@1.x ---- 1.0.0 <= version < 2.0.0
npm install name@1.2.* ---- 1.2.0 <= version < 1.3.0
npm install name@1.* ---- 1.0.0 <= version < 2.0.0
npm install name@* ---- 0.0.0 <= version

2.带^的版本表示法
从左边起第一个不为0的版本号不允许改变

npm install name@^1.2.3 ---- 1.2.3 <= version < 2.0.0 
npm install name@^0.2.3 ---- 0.2.3 <= version < 0.3.0
npm install name@^0.0.3 ---- 0.0.3 <= version < 0.1.0
npm install name@^1.2.x ---- 1.2.0 <= version <2.0.0
npm install name@^0.0.x ---- 0.0.0 <= version <0.1.0
npm install name@^0.0 ---- 0.0.0 <= version <0.1.0

3.带~的版本表示法
如果有小版本(minor)定义,允许patch版本变动,否则的话就允许minor变动

npm install name@~1.2.3 ----- 1.2.3 <= version <1.3.0
npm install name@~1.2 ----- 1.2.0 <= version <1.3.0 (Same as 1.2.x)
npm install name@~1 ----- 1.0.0 <= version <2.0.0 (Same as 1.x)
npm install name@~0.2.3 ----- 0.2.3 <= version <0.3.0
npm install name@~0.2 ----- 0.2.0 <= version <0.3.0 (Same as 0.2.x)
npm install name@~0 ----- 0.0.0 <= version <1.0.0 (Same as 0.x)

shadowQiao
63 声望1 粉丝