我想知道如何配置 .npmrc
文件,以便我可以拥有一个默认注册表和一个不同范围的带有身份验证的注册表。
我将 Nexus 用于私有(private)存储库,但我不确定如何为范围注册表设置身份验证,只有默认注册表。
例如我的 ~/.npmrc
文件是:
registry=https://registry.npmjs.org/
@test-scope:registry=http://nexus:8081/nexus/content/repositories/npm-test/
[email protected]
_auth="…"
npm publish
对于范围为 test-scope
的包, 我收到身份验证错误。_auth
仅适用于 registry=...
部分。有没有办法为 @test-scope:registry=...
指定认证 key ?部分?因此,在对 NPM 源代码进行一些挖掘之后,发现有一种方法可以做到这一点。
我的解决方案如下:
registry=https://registry.npmjs.org/
@test-scope:registry=http://nexus:8081/nexus/content/repositories/npm-test/
//nexus:8081/nexus/content/repositories/npm-test/:username=admin
//nexus:8081/nexus/content/repositories/npm-test/:_password=YWRtaW4xMjM=
email=…
@test-scope
指定具有范围的包应发布到与默认值不同的注册表 registry=
执行 npm publish
时命令。//nexus:8081/...
开头的两行用于为 username
指定作用域存储库的凭据和 _password
哪里_password
是来自之前使用的 _auth
的 base64 编码密码组件证书。registry=https://registry.npmjs.org/
@test-scope:registry=http://nexus:8081/nexus/content/repositories/npm-test/
//nexus:8081/nexus/content/repositories/npm-test/:username=admin
//nexus:8081/nexus/content/repositories/npm-test/:_password=${BASE64_PASSWORD}
email=…
email=
必须指定行。
关于node.js - 如何在 .npmrc 中为范围注册表设置 _auth?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49404870/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |