npm install 与 update

编程入门 行业动态 更新时间:2024-10-28 18:27:52
本文介绍了npm install 与 update - 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

npm install 和 npm update 之间的实际区别是什么?我应该什么时候使用哪个?

What is the practical difference between npm install and npm update? When should I use which?

推荐答案

npm install 的区别 和 npm update 处理 package.json 中指定的包版本:

The difference between npm install and npm update handling of package versions specified in package.json:

{ "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 } }

总结:唯一的大区别是一个已经安装的带有模糊版本控制的模块 ...

Summary: The only big difference is that an already installed module with fuzzy versioning ...

  • 被 npm install
  • 忽略
  • 由 npm update
  • 更新

另外:install 和 update 默认以不同的方式处理 devDependencies

Additionally: install and update by default handle devDependencies differently

  • npm install 将 安装/更新 devDependencies,除非添加了 --production 标志
  • npm update 将忽略 devDependencies,除非添加了 --dev 标志
  • npm install will install/update devDependencies unless --production flag is added
  • npm update will ignore devDependencies unless --dev flag is added

为什么要使用 npm install?

因为 npm install 除了处理 package.json 中的依赖项之外,还能做更多的事情.正如您在 npm install 中所见,您可以...

Because npm install does more when you look besides handling your dependencies in package.json. As you can see in npm install you can ...

  • 手动安装节点模块
  • 使用 npm install -g
  • 将它们设置为 global(将它们放在 shell 的 PATH 中)
  • 安装 git 标签描述的某些版本
  • 从 git url 安装
  • 使用 --force
  • 强制重新安装
  • manually install node-modules
  • set them as global (which puts them in the shell's PATH) using npm install -g <name>
  • install certain versions described by git tags
  • install from a git url
  • force a reinstall with --force

更多推荐

npm install 与 update

本文发布于:2023-06-08 14:32:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/583119.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:npm   install   update

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!