yarn publish uses wrong credentials
Do you want to request a feature or report a bug? Report a bug
What is the current behavior?
When publishing yarn uses the authentication of the registry configured in yarnrc, not the registry configured in publishConfig.registry in the package.json.
If the current behavior is a bug, please provide the steps to reproduce.
- Create a package with a registry in the yarnrc and a different registry in the package.json's publishConfig
- Configure npmrc with authentication scoped to the normal registry and a different authenciation scoped to the registry used in publishConfig
- Try to publish
- See publish failure, debug requests and note that the authorization header for the user configured in the regular registry
Our config:
# .yarnrc
registry "https://nexus.internal/nexus/content/groups/my-npm-group/"
# .npmrc
//nexus.internal/nexus/content/groups/my-npm/:username=some-user
//nexus.internal/nexus/content/groups/my-npm/:_password=some-pwd
//nexus.internal/nexus/content/groups/my-npm/:always-auth=true
//nexus.internal/nexus/content/groups/my-npm/:[email protected]
# .npmrc used by Jenkins in NPM_CONFIG_USERCONFIG
//nexus.internal/nexus/content/repositories/my-npm-releases/:username=other-user
//nexus.internal/nexus/content/repositories/my-npm-releases/:_password=other-pwd
//nexus.internal/nexus/content/repositories/my-npm-releases/:always-auth=true
//nexus.internal/nexus/content/repositories/my-npm-releases/:[email protected]
{
"//": "...",
"publishConfig": {
"registry": "https://nexus.internal/nexus/content/repositories/my-npm-releases/"
}
}
What is the expected behavior?
Yarn should use the authentication scoped to the publishConfig registry, not the regular registry
Please mention your node.js, yarn and operating system version.
- node 8.11.3
- yarn 1.9.4
- macOS High Sierra
@bgotink A workaround for now seems to pass --registry argument to yarn publish instead of using publishConfig.
We don't run yarn publish directly (we use lerna) so I don't think we can make that happen. I've worked around it by telling lerna to use npm to publish, but I'd much rather not use npm at all.
@bgotink We also use lerna. In root package.json we have a task "release": "lerna run release". And in each package we have a task similar to this "release": "yarn build && yarn publish --non-interactive --registry http://myregistry.com/"
This tasks and using token in .npmrc allow us to publish packages with our CI.