npm-cli-login icon indicating copy to clipboard operation
npm-cli-login copied to clipboard

Fix an issue with trailing slash in registry URL

Open daniel-braga opened this issue 5 years ago • 6 comments

Fixes issue #20

daniel-braga avatar Feb 28 '19 13:02 daniel-braga

What does one have to do for this to be merged? :space_invader:

jurajseffer avatar Aug 16 '19 12:08 jurajseffer

Ping @czardoz ?

squarebracket avatar Jan 14 '20 21:01 squarebracket

Ping @czardoz ? I've tested this, works fine. I can now supply the URL with or without trailing slash. We would really appreciate having this PR merged.

This bug is really annoying when using Artifactory, where URL paths look like /artifactory/api/npm/repo-name/. Without this fix, we have to spread workarounds all over our build scripts.

heidemn avatar Apr 27 '20 10:04 heidemn

Any update on this PR?

saquibmian avatar Oct 19 '20 20:10 saquibmian

@saquibmian in the meantime we're using the following workaround. Works fine with all NPM registries where you get a password or token that doesn't expire too soon (tested with Artifactory and Azure DevOps).

  • In CI build config: Define secret multi-line variable e.g. MY_NPMRC="..." (either copy the required contents as provided by your NPM registry, or login once manually using npm login and extract the contents from ~/.npmrc)
  • In CI build script: echo "$MY_NPMRC" > ~/.npmrc. If you need the NPM credentials in a Docker build, export MY_NPMRC and pass the variable into the build using docker build --build-arg MY_NPMRC ...
  • In case that your CI doesn't support multi-line variables, you can replace the newline with another character, e.g. !, and then: echo "$MY_NPMRC" | tr '!' '\n' > ~/.npmrc

What I don't understand: Why doesn't npm login support a password on the commandline out of the box?

heidemn avatar Oct 21 '20 20:10 heidemn

I have a package to publish via npm publish, this contains package.json with

"publishConfig": { "registry": "https://myregistry.domain.com/" }}

and setting

NPM_REGISTRY=https://myregistry.domain.com/

I tried all combinations with and without final slash and I can't get the package to publish, always wrong credentials, this pull request might help.

masterkain avatar Jun 17 '22 02:06 masterkain