对于在 2021 年发现这一点的任何人,yarn 现在可以与scopes、 private registries 和 auth一起使用。
例如,我已经发布了私有包,例如Verdaccio(Sinopia@my-company-private-scope/my-package的分支)服务器,我的配置如下:.npmrc
; Lines starting with ; are for .npmrc file comments
; yarn 1.22.10 seems to default registry to https://registry.yarnpkg.com
; no matter what I put here /shrug
; registry=https://registry.npmjs.com/
@my-company-private-scope:registry=https://npm.my-company.com/
//npm.my-company.com/:_authToken=TOKEN
; I did not seem to need this, as
; yarn still installed public and private packages successfully
; based on what ended up in my yarn.lock file
; //npm.my-company.com/:always-auth true
看起来npm 也支持 scopes,虽然yarn unpublish不存在,但npm unpublish @my-company-private-scope/my-package@1.0.1-5效果也很好。
我还不需要在多个私有服务器上尝试多个范围(尽管可能),但是我也没有看到任何好的理由它也不能很好地工作。