npm whoami: Usage & Common CI Errors
Confirm which user your registry token authenticates as.
npm whoami returns the username associated with the current auth token. It is the simplest way to verify registry auth before a publish.
What it does
Calls the registry with the configured token and prints the resolved username. With --registry it checks auth against a specific registry. It is read-only and a reliable pre-publish auth check.
Common usage
Terminal
npm whoami # username for default registry
npm whoami --registry=https://npm.acme.devCommon CI error: ENEEDAUTH from whoami
npm whoami fails with "npm error code ENEEDAUTH / This command requires you to be logged in". The token is missing, expired, or scoped to the wrong registry. Fix the token in .npmrc and gate publish on a passing whoami so auth fails fast, not mid-publish.
.github/workflows/release.yml
npm whoami || { echo "npm auth not configured"; exit 1; }Related guides
npm login: Usage, Options & Common CI Errorsnpm login authenticates to a registry for the interactive user - but CI should use a token, not npm login. Us…
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…