fra*_*ogs 17 javascript node.js npm npm-install .npmrc
我需要为两个不同的范围设置多个 npm authToken,但两个范围都位于同一注册表中。
@scope1:registry=https://registry.npmjs.org/
@scope2:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
Run Code Online (Sandbox Code Playgroud)
我尝试将 authToken 添加到每个范围,如下所示:
@scope1:registry=https://registry.npmjs.org/:_authToken=${TOKEN_1}
@scope2:registry=https://registry.npmjs.org/:_authToken=${TOKEN_2}
Run Code Online (Sandbox Code Playgroud)
但是当我405尝试安装软件包时出现错误。
我尝试阅读docs,但找不到为同一注册表上的不同范围指定不同令牌的方法。
这是一个有点老套的答案——但它确实有效。至少在我使用它的 github 包上是这样。我认为它可以在 npmjs.org 上运行,但我没有任何私有包可供测试。
@scope1:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=TOKEN1
@scope2:registry=https://npm.pkg.github.com:443
//npm.pkg.github.com:443/:_authToken=TOKEN2
@scope3:registry=https://npm.pkg.github.com:0443
//npm.pkg.github.com:0443/:_authToken=TOKEN3
Run Code Online (Sandbox Code Playgroud)
基本上,只需通过指定端口使它们成为不同的注册表,即使它们是相同的端口。
| 归档时间: |
|
| 查看次数: |
4460 次 |
| 最近记录: |