npm login: Usage, Options & Common CI Errors
Authenticate to an npm registry.
npm login (alias npm adduser) authenticates you to a registry and stores the auth token in .npmrc. It is interactive, so CI uses a pre-provisioned token instead.
What it does
Prompts for credentials (or opens a browser for the web login flow) and writes an auth token to your user .npmrc for the configured registry. --scope and --registry target a specific scope or private registry.
Common usage
Terminal
npm login # default registry
npm login --scope=@acme --registry=https://npm.acme.dev
npm whoami # confirm who you areCommon CI error: npm login hangs
A CI job calling npm login blocks forever on the interactive prompt. Do not run npm login in CI - write an automation token straight into .npmrc so npm publish/install authenticates without prompting.
.github/workflows/release.yml
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
npm whoami # verify authRelated guides
npm whoami: Usage & Common CI Errorsnpm whoami prints the username for your current registry token - the fastest auth smoke test in release CI. U…
npm E401 / ENEEDAUTH - Fix Registry Auth and .npmrc Token in CIFix npm E401 "Incorrect or missing auth token" and ENEEDAUTH in CI - a private registry rejecting the request…
npm publish: Usage, Options & Common ErrorsHow npm publish ships a package to the registry, scoped/access flags, and the E403/E409 auth and version-exis…