Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CLI --@scope:registry flag to override scoped registry defined in .npmrc #219

Closed
maryiam opened this issue Nov 13, 2019 · 5 comments · May be fixed by #844
Closed

Use CLI --@scope:registry flag to override scoped registry defined in .npmrc #219

maryiam opened this issue Nov 13, 2019 · 5 comments · May be fixed by #844

Comments

@maryiam
Copy link

maryiam commented Nov 13, 2019

I'm using semantic-release-npm to publish a package on my Nexus registry. My package is scoped.

I have the following config my .npmrc that defines a rule for installing my scoped package (get it from Nexus proxy repository):

@myscope:registry=https://my-nexus-proxy-npm-group-url

If I use npm cli to publish my package, I am able to override the .npmrc :

  • with the --@scope:registry arg (and like mentioned here):
npm publish --@scope:registry=my-nexus-registry-URL
  • or with adding this config to my package.json
"publishConfig": {
    "@myscope:registry": "my-nexus-registry-URL"
  }

I am not able to achieve the same result with semantic-release-npm. The command that it uses to publish doesn't support the arg --@scope:registry, only the --registry arg is supported:

npm publish --userconfig /path/to/.npmrc --registry URL

Is there any way that I can configure semantic-release to use a scoped registry instead? Even when I try to configure the publishConfig attribute in my package.json like this

"publishConfig": {
    "@myscope:registry": "my-nexus-registry-URL"
  }

it's not working because the get-registry.js is taking into account only the registry attribute without supporting the scoped registry config.

Thanks.

@pvdlg
Copy link
Member

pvdlg commented Nov 13, 2019

The config @myscope:registry allow to set a registry that will be used only package in @scope.
As you can see in this test we do read the @myscope:registry property from .npmrc and that's the value that is passed to --registry.

So if you have @myscope:registry=https://my-nexus-proxy-npm-group-url in your .npmrc and your package is in the scope @myscope then the registry https://my-nexus-proxy-npm-group-url will be used for the publish step.

Please provide:

  • A description of the actual issue you are encountering (error message? package published on the wrong registry?)
  • The exact content of your ~/.npmrc and ./.npmrc
  • The exact version of @semantic-release/npm you are using
  • The semantic-release logs

@pvdlg
Copy link
Member

pvdlg commented Nov 28, 2019

Closing as no response provided. Feel free to re-open if you still experience an issue and provide the info requested above.

@brncsk
Copy link

brncsk commented Sep 29, 2020

I think this should be reopened. The scoped registry should be picked up from package.json's publishConfig as well as from .npmrc.

I've just run into this, and this issue is clearly stated in the original report as well.

@jameshartig
Copy link
Contributor

We're running into this issue. Setting NPM_CONFIG_REGISTRY does not correctly set --@scope:registry= and just uses --registry instead.

@NNNaix
Copy link

NNNaix commented Jun 25, 2021

Hello, @jameshartig .

Just uses --registry is not enough beacuse if setting @scope:registry in .npmrc it will always have a higher priority.

But the scope registry in .npmrc is setting for installing. For example i develop a boilerplate and i don't want npm publish using registry from .npmrc, and --registry will not work.

Kenneth-Sills added a commit to Kenneth-Sills/semantic-release-npm that referenced this issue Jul 30, 2024
This stops a niche issue when using Gitlab registries, where setting the
`.npmrc` to pull packages from the instance-wide registry while also setting
the `package.json:publishConfig` to push to the project-local registry
for a given `@scope` would pass the incorrect `--registry` flag to `npm publish`
as well as associate the `NPM_TOKEN` with the wrong URL in the
generated userconfig file.

This DOES NOT resolve semantic-release#219. So `--registry` is still technically ignored for
scoped packages. See
[npm/cli#7043](npm/cli#7043)
for more details on that.

I made sure not to affect the priority of other resolutions to avoid any
breaking changes. An additional test has been added for this specific
case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants