Skip to content

Yarn writes registry.yarnpkg.com to lockfile when private scoped packages is from registry.npmjs.org #4157

@stieg

Description

@stieg

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
I have something like the following in my ~/.npmrc file:

@mycompany:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

This is necessary so I can login to my private repo and get the packages I need to build locally.

When I add a new package like @mycompany/foo I would expect an entry in the yarn.lock file to look something like this:

"@mycompany/foo@^1.1.0":
  version "1.1.0"
  resolved "https://registry.npmjs.org/@mycompany/foo/-/foo-1.1.0.tgz#103034ba565c288eb781b1fd1065c9f05dfb90f9"

Yeah... not so much. Instead it looks like this:

"@mycompany/foo@^1.1.0":
  version "1.1.0"
  resolved "https://registry.yarnpkg.com/@mycompany/foo/-/foo-1.1.0.tgz#103034ba565c288eb781b1fd1065c9f05dfb90f9"

Uncool yarn. This causes my CI to break because it will try and dig up the packages at registry.yarnpkg.com. Since this is a private registry the login will fail (since the registry is hosted on registry.npmjs.org) and thus it will cause other systems to fail to install packages.

Here is how to reproduce:

  1. Setup a private repo on npm with some namespace
  2. Set your .npmrc file to something like the one I provided above (except you replace the scope mycompany with your own scope, and set a valid auth token of course), and run yarn add <your scoped package>. You can do this by doing npm login --registry=https://registry.npmjs.org --scope=@<your scope name>. I would use yarn login but that doesn't work :(
  3. Add a package from your scope using yarn add
  4. Push a trivial update to that package in your scope.
  5. Tell yarn to upgrade the package.

You will see that the URL gets changed in the lock file.

Please mention your node.js, yarn and operating system version.
node: 8.2.1
yarn: 0.28.4
OS: Fedora 26

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions