目录
目录
分发标签 (dist-tags) 是人类可读的标签,你可以使用它来组织和标记你发布的不同版本的包。dist-tags 补充 语义版本控制。除了比语义版本编号更易于人类阅读之外,标签还允许发布者更有效地分发他们的包。
¥Distribution tags (dist-tags) are human-readable labels that you can use to organize and label different versions of packages you publish. dist-tags supplement semantic versioning. In addition to being more human-readable than semantic version numbering, tags allow publishers to distribute their packages more effectively.
有关详细信息,请参阅 dist-tag
CLI 文档。
¥For more information, see the dist-tag
CLI documentation.
注意:由于 dist-tags 与语义版本共享一个命名空间,因此避免与现有版本号冲突的 dist-tags。我们建议避免使用以数字或字母 "v" 开头的 dist-tags。
¥Note: Since dist-tags share a namespace with semantic versions, avoid dist-tags that conflict with existing version numbers. We recommend avoiding dist-tags that start with a number or the letter "v".
发布带有 dist-tag 的包
¥Publishing a package with a dist-tag
默认情况下,运行 npm publish
将使用 latest
dist-tag 标记你的包。要使用另一个 dist-tag,请在发布时使用 --tag
标志。
¥By default, running npm publish
will tag your package with the latest
dist-tag. To use another dist-tag, use the --tag
flag when publishing.
-
在命令行上,导航到包的根目录。
¥On the command line, navigate to the root directory of your package.
cd /path/to/package
-
运行以下命令,将
<tag>
替换为你要使用的标签:¥Run the following command, replacing
<tag>
with the tag you want to use:npm publish --tag <tag>
示例
¥Example
要发布带有 "beta" dist-tag 的包,请在命令行中,在包的根目录中运行以下命令:
¥To publish a package with the "beta" dist-tag, on the command line, run the following command in the root directory of your package:
npm publish --tag beta
将 dist-tag 添加到包的特定版本
¥Adding a dist-tag to a specific version of your package
-
在命令行上,导航到包的根目录。
¥On the command line, navigate to the root directory of your package.
cd /path/to/package
-
运行以下命令,将
<package_name>
替换为你的包的名称,将<version>
替换为你的包版本号,将<tag>
替换为分发标签:¥Run the following command, replacing
<package_name>
with the name of your package,<version>
with your package version number, and<tag>
with the distribution tag:npm dist-tag add <package-name>@<version> [<tag>]
示例
¥Example
要将 "stable" 标签添加到 "example-package" 包的 1.4.0 版本,你将运行以下命令:
¥To add the "stable" tag to the 1.4.0 version of the "example-package" package, you would run the following command:
npm dist-tag add example-package@1.4.0 stable