工作中会经常用到npm install
或是npm update
,那这两个命令有什么区别呢
可以用一个文件来看下
{
"name": "my-project",
"version": "1.0", // install update
"dependencies": { // ------------------
"already-installed-versionless-module": "*", // ignores "1.0" -> "1.1"
"already-installed-semver-module": "^1.4.3" // ignores "1.4.3" -> "1.5.2"
"already-installed-versioned-module": "3.4.1" // ignores ignores
"not-yet-installed-versionless-module": "*", // installs installs
"not-yet-installed-semver-module": "^4.2.1" // installs installs
"not-yet-installed-versioned-module": "2.7.8" // installs installs
}
}
由此可以看到两者之间的差别就是对于已经安装的包,没有明确版本号的
npm install会忽略
npm update会升级
另外, install
和update
在devDependecies
上也是有差别的
npm install
默认会安装devDependecies
,除非加上--production
参数npm update
不会默认安装,除非手动加上--dev
参数npm i -g
git url
安装,npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
npm install --force
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有