乐闻世界logo
搜索文章和话题

How can I remove a tag from npm?

1个答案

1

In npm, removing a specific tag version typically involves two steps: first, remove the version associated with the tag, then remove the tag itself. Here are the specific steps:

Step 1: Remove the Version Associated with the Tag

To remove a specific version, you can use the npm unpublish command. Note that according to npm's policy, you can only remove versions within 72 hours of publication. If this time limit is exceeded, you will need to contact the npm support team for removal.

Command format:

bash
npm unpublish [package name]@[version number]

For example, if you have a package named example-package and want to remove version 1.0.1, you can execute:

bash
npm unpublish example-package@1.0.1

Step 2: Remove the Tag

In npm, tags are typically used to mark specific versions, such as latest. To remove a specific tag, you can use the npm dist-tag rm command.

Command format:

bash
npm dist-tag rm [package name] [tag name]

For example, if you want to remove the beta tag for the example-package package, you can execute:

bash
npm dist-tag rm example-package beta

Example

Suppose you previously tagged version 1.0.1 of example-package with a beta tag and now need to remove it entirely. You can follow these steps:

  1. Remove version 1.0.1:
    bash
    npm unpublish example-package@1.0.1
  2. Remove the beta tag:
    bash
    npm dist-tag rm example-package beta

After executing these steps, the beta version and its tag for example-package will be completely removed. If you encounter any issues, refer to the npm documentation or contact the npm support team for assistance.

2024年6月29日 12:07 回复

你的答案