We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
语义版本控制的概念很简单:所有的版本都有 3 个数字:x.y.z。
当发布新的版本时,不仅仅是随心所欲地增加数字,还要遵循以下规则:
该约定在所有编程语言中均被采用,每个npm软件包都必须遵守该约定,这一点非常重要,因为整个系统都依赖于此。
npm
为什么这么重要?
因为 npm 设置了一些规则,可用于在 package.json 文件中选择要将软件包更新到的版本(当运行 npm update 时)。
npm update
规则使用了这些符号:
^
~
>
>=
<
<=
=
-
||
这些规则的详情如下:
可以合并其中的一些符号,例如 1.0.0 || >=1.1.0 <1.2.0,即使用 1.0.0 或从 1.1.0 开始但低于 1.2.0 的版本。
1.0.0 || >=1.1.0 <1.2.0
还有其他的规则:
使用 npm 的语义版本控制·node.js
如果 npm 脚本里面需要执行多个任务,那么需要明确它们的执行顺序。
如果是并行执行(即同时的平行执行),可以使用&符号。
&
npm run script1.js & npm run script2.js
如果是继发执行(即只有前一个任务成功,才执行下一个任务),可以使用&&符号。
&&
npm run script1.js && npm run script2.js
这两个符号是 Bash 的功能。
npm scripts 使用指南·阮一峰
The text was updated successfully, but these errors were encountered:
Popxie
No branches or pull requests
使用 npm 的语义版本控制
语义版本控制的概念很简单:所有的版本都有 3 个数字:x.y.z。
当发布新的版本时,不仅仅是随心所欲地增加数字,还要遵循以下规则:
该约定在所有编程语言中均被采用,每个
npm
软件包都必须遵守该约定,这一点非常重要,因为整个系统都依赖于此。为什么这么重要?
因为
npm
设置了一些规则,可用于在 package.json 文件中选择要将软件包更新到的版本(当运行npm update
时)。规则使用了这些符号:
^
插入号~
波浪号>
>=
<
<=
=
-
||
这些规则的详情如下:
^
: 如果写入的是 ^0.13.0,则当运行 npm update 时,会更新到补丁版本和次版本:即 0.13.1、0.14.0、依此类推。~
: 如果写入的是 〜0.13.0,则当运行 npm update 时,会更新到补丁版本:即 0.13.1 可以,但 0.14.0 不可以。>
: 接受高于指定版本的任何版本。>=
: 接受等于或高于指定版本的任何版本。<=
: 接受等于或低于指定版本的任何版本。<
: 接受低于指定版本的任何版本。=
: 接受确切的版本。-
: 接受一定范围的版本。例如:2.1.0 - 2.6.2。||
: 组合集合。例如 < 2.1 || > 2.6。可以合并其中的一些符号,例如
1.0.0 || >=1.1.0 <1.2.0
,即使用 1.0.0 或从 1.1.0 开始但低于 1.2.0 的版本。还有其他的规则:
使用 npm 的语义版本控制·node.js
npm 执行顺序
如果 npm 脚本里面需要执行多个任务,那么需要明确它们的执行顺序。
如果是并行执行(即同时的平行执行),可以使用
&
符号。npm run script1.js & npm run script2.js
如果是继发执行(即只有前一个任务成功,才执行下一个任务),可以使用
&&
符号。npm run script1.js && npm run script2.js
这两个符号是 Bash 的功能。
npm scripts 使用指南·阮一峰
The text was updated successfully, but these errors were encountered: