dependabot/npm_and_yarn/main/proc-log-7.0.0
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: npm-login |
| 3 | section: 1 |
| 4 | description: Login to a registry user account |
| 5 | github_repo: npm/cli |
| 6 | github_branch: release/v9 |
| 7 | github_path: docs/lib/content/commands/npm-login.md |
| 8 | redirect_from: |
| 9 | - /cli-documentation/v9/cli-commands/login |
| 10 | - /cli-documentation/v9/cli-commands/npm-login |
| 11 | - /cli-documentation/v9/commands/login |
| 12 | - /cli-documentation/v9/commands/npm-login |
| 13 | - /cli-documentation/v9/login |
| 14 | - /cli-documentation/v9/npm-login |
| 15 | - /cli/v9/cli-commands/login |
| 16 | - /cli/v9/cli-commands/npm-login |
| 17 | - /cli/v9/commands/login |
| 18 | - /cli/v9/login |
| 19 | - /cli/v9/npm-login |
| 20 | --- |
| 21 | |
| 22 | ### Synopsis |
| 23 | |
| 24 | ```bash |
| 25 | npm login |
| 26 | ``` |
| 27 | |
| 28 | Note: This command is unaware of workspaces. |
| 29 | |
| 30 | ### Description |
| 31 | |
| 32 | Verify a user in the specified registry, and save the credentials to the `.npmrc` file. If no registry is specified, the default registry will be used (see [`config`](/cli/v9/using-npm/config)). |
| 33 | |
| 34 | When using `legacy` for your `auth-type`, the username and password, are read in from prompts. |
| 35 | |
| 36 | To reset your password, go to [https://www.npmjs.com/forgot](https://www.npmjs.com/forgot) |
| 37 | |
| 38 | To change your email address, go to [https://www.npmjs.com/email-edit](https://www.npmjs.com/email-edit) |
| 39 | |
| 40 | You may use this command multiple times with the same user account to authorize on a new machine. When authenticating on a new machine, the username, password and email address must all match with your existing record. |
| 41 | |
| 42 | ### Configuration |
| 43 | |
| 44 | #### `registry` |
| 45 | |
| 46 | - Default: "https://registry.npmjs.org/" |
| 47 | - Type: URL |
| 48 | |
| 49 | The base URL of the npm registry. |
| 50 | |
| 51 | #### `scope` |
| 52 | |
| 53 | - Default: the scope of the current project, if any, or "" |
| 54 | - Type: String |
| 55 | |
| 56 | Associate an operation with a scope for a scoped registry. |
| 57 | |
| 58 | Useful when logging in to or out of a private registry: |
| 59 | |
| 60 | ``` |
| 61 | # log in, linking the scope to the custom registry |
| 62 | npm login --scope=@mycorp --registry=https://registry.mycorp.com |
| 63 | |
| 64 | # log out, removing the link and the auth token |
| 65 | npm logout --scope=@mycorp |
| 66 | ``` |
| 67 | |
| 68 | This will cause `@mycorp` to be mapped to the registry for future installation of packages specified according to the pattern `@mycorp/package`. |
| 69 | |
| 70 | This will also cause `npm init` to create a scoped package. |
| 71 | |
| 72 | ``` |
| 73 | # accept all defaults, and create a package named "@foo/whatever", |
| 74 | # instead of just named "whatever" |
| 75 | npm init --scope=@foo --yes |
| 76 | ``` |
| 77 | |
| 78 | #### `auth-type` |
| 79 | |
| 80 | - Default: "web" |
| 81 | - Type: "legacy" or "web" |
| 82 | |
| 83 | What authentication strategy to use with `login`. Note that if an `otp` config is given, this value will always be set to `legacy`. |
| 84 | |
| 85 | ### See Also |
| 86 | |
| 87 | - [npm registry](/cli/v9/using-npm/registry) |
| 88 | - [npm config](/cli/v9/commands/npm-config) |
| 89 | - [npmrc](/cli/v9/configuring-npm/npmrc) |
| 90 | - [npm owner](/cli/v9/commands/npm-owner) |
| 91 | - [npm whoami](/cli/v9/commands/npm-whoami) |
| 92 | - [npm token](/cli/v9/commands/npm-token) |
| 93 | - [npm profile](/cli/v9/commands/npm-profile) |