npm-cli-login
npm-cli-login copied to clipboard
Fix an issue with trailing slash in registry URL
Fixes issue #20
What does one have to do for this to be merged? :space_invader:
Ping @czardoz ?
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.
Any update on this PR?
@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 usingnpm 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 usingdocker 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?
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.