I need to set up multiple npm tokens that are under two different scopes
@scope1:registry=https://registry.npmjs.org/
@scope2:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
I have tried to add the an auth Token to each scope
@scope1:registry=https://registry.npmjs.org/:_authToken=${TOKEN_1}
@scope2:registry=https://registry.npmjs.org/:_authToken=${TOKEN_2}
But I am getting a 405
when I am trying to install a package.
I tried looking up the docs: https://docs.npmjs.com/using-npm/config but I cannot find a way to specify different tokens for different scopes
I contacted the npm support and got the following response:
Users cannot mix-and-match auth for a single registry. We recommend having a single npm user that's granted access to all of the packages and to use the token for that user.
This is a bit of a hacky answer - but it works. At least on github packages where I am using it. I assume it works on npmjs.org but I don't have any private packages there to test.
@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
Basically, just make them different registries by specifying a port even though it is the same port.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.