如何将 NPM 包迁移到组织 @scope [英] How to migrate NPM package to an organization @scope

查看:122
本文介绍了如何将 NPM 包迁移到组织 @scope的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NPM 最近为这些模块引入了@scopes/组织.是否有将现有模块迁移到组织的好方法?是否有任何工具可以为大量包自动化?NPM 是否支持重定向,以便其他软件仍然可以使用旧名称,但会收到应更新的通知?

NPM has recently introduced @scopes / organizations for the modules. Is there a good way to migrate existing modules to the organization? Are there any tools for automating it for a large number of packages? Does NPM support redirects, so that other software could still use the old name, yet get a notification that it should be updated?

推荐答案

您可以从以下位置更改 package.json:

You can change your package.json from:

"name": "project-name"

到:

"name": "@scope/project-name"

并发布包:

npm publish --access=public

更新: --access=public 参数需要使范围包公开 - 否则默认情况下它将是私有的.您可以在 package.jsonpublishConfig 部分将 access 设置为 "public" 而不是命令行参数代码>:

Update: The --access=public argument is needed to make the scoped package public - otherwise it will be private by default. Instead of the command-line argument you can set access to "public" in the publishConfig section of your package.json:

"publishConfig": {
  "access": "public"
}

(感谢 Danilo BargenGreg Pratt 在评论中指出!)

(Thanks to Danilo Bargen and Greg Pratt for pointing it out in the comments!)

参见:https://docs.npmjs.com/getting-started/scoped-包

npm 不支持从旧名称重定向到新名称,但是您可以通过以下方式弃用旧包:

The npm doesn't support redirects from old names to new names but you can deprecate the old package with:

npm deprecate <pkg>[@<version>] <message>

这样安装旧版本的人就会收到通知,他们应该安装另一个包.

So that people who install the old version would be notified that they should install another package instead.

参见:https://docs.npmjs.com/cli/deprecate

这篇关于如何将 NPM 包迁移到组织 @scope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆