npm-update
选择命令行版本:
See Details
目录
概要
¥Synopsis
npm update [<pkg>...]aliases: up, upgrade, udpate
描述
¥Description
此命令会将列出的所有包更新到最新版本(由 tag 配置 指定),同时尊重包及其依赖的 semver 约束(如果它们也需要相同的包)。
¥This command will update all the packages listed to the latest version (specified by the tag config), respecting the semver constraints of both your package and its dependencies (if they also require the same package).
它还将安装缺少的包。
¥It will also install missing packages.
如果指定了 -g 标志,此命令将更新全局安装的包。
¥If the -g flag is specified, this command will update globally installed packages.
如果未指定包名称,则将更新指定位置(全局或本地)中的所有包。
¥If no package name is specified, all packages in the specified location (global or local) will be updated.
请注意,默认情况下 npm update 不会更新项目 package.json 中直接依赖的 semver 值。如果你还想更新 package.json 中的值,你可以运行:npm update --save(或将 save=true 选项添加到 配置文件 以使其成为默认行为)。
¥Note that by default npm update will not update the semver values of direct dependencies in your project package.json. If you want to also update values in package.json you can run: npm update --save (or add the save=true option to a configuration file to make that the default behavior).
示例
¥Example
对于下面的示例,假设当前包是 app,它依赖于依赖 dep1(dep2、.. 等)。dep1 的已发布版本是:
¥For the examples below, assume that the current package is app and it depends on dependencies, dep1 (dep2, .. etc.). The published versions of dep1 are:
{"dist-tags": { "latest": "1.2.2" },"versions": ["1.2.2","1.2.1","1.2.0","1.1.2","1.1.1","1.0.0","0.4.1","0.4.0","0.2.0"]}
插入符号依赖
¥Caret Dependencies
如果 app 的 package.json 包含:
¥If app's package.json contains:
"dependencies": {"dep1": "^1.1.1"}
那么 npm update 会安装 dep1@1.2.2,因为 1.2.2 就是 latest,1.2.2 满足 ^1.1.1。
¥Then npm update will install dep1@1.2.2, because 1.2.2 is latest and 1.2.2 satisfies ^1.1.1.