LinuxCommandLibrary

npm-login

authenticates with an npm registry

TLDR

Login to npm registry

$ npm login
copy
Login to specific registry
$ npm login --registry=[https://registry.example.com]
copy
Login with scope
$ npm login --scope=@[myorg]
copy
Check login status
$ npm whoami
copy
Logout
$ npm logout
copy

SYNOPSIS

npm login [options]

DESCRIPTION

npm login (also npm adduser) authenticates with an npm registry. Credentials are stored in ~/.npmrc and used for publishing and accessing private packages.
For npm.js, this enables publishing packages and accessing private organization packages.

PARAMETERS

--registry url

Registry URL.
--scope scope
Associate login with scope.
--auth-type type
Authentication type.

AUTHENTICATION FLOW

$ # Standard login
npm login
# Enter username, password, email, OTP if enabled

# Verify
npm whoami
# Output: your-username

# View token
npm token list
copy

NPMRC LOCATIONS

$ ~/.npmrc           # User config
./.npmrc           # Project config
/etc/npmrc         # Global config
copy

CAVEATS

Tokens stored in plaintext in .npmrc. Use npm token for token management. 2FA may be required.

HISTORY

npm login has been part of npm since its early versions, evolving to support 2FA and multiple registries.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community