1 ---
2 title: npm-login
3 section: 1
4 description: Login to a registry user account
5 github_repo: npm/cli
6 github_branch: latest
7 github_path: docs/lib/content/commands/npm-login.md
8 redirect_from:
9 - /cli-commands/login
10 - /cli-commands/npm-login
11 - /cli-documentation/cli-commands/login
12 - /cli-documentation/cli-commands/npm-login
13 - /cli-documentation/commands/login
14 - /cli-documentation/commands/npm-login
15 - /cli-documentation/login
16 - /cli-documentation/npm-login
17 - /cli-documentation/v11/cli-commands/login
18 - /cli-documentation/v11/cli-commands/npm-login
19 - /cli-documentation/v11/commands/login
20 - /cli-documentation/v11/commands/npm-login
21 - /cli-documentation/v11/login
22 - /cli-documentation/v11/npm-login
23 - /cli/cli-commands/login
24 - /cli/cli-commands/npm-login
25 - /cli/commands/login
26 - /cli/commands/npm-login
27 - /cli/login
28 - /cli/npm-login
29 - /cli/v11/cli-commands/login
30 - /cli/v11/cli-commands/npm-login
31 - /cli/v11/commands/login
32 - /cli/v11/login
33 - /cli/v11/npm-login
34 - /commands/login
35 - /commands/npm-login
36 ---
37
38 ### Synopsis
39
40 ```bash
41 npm login
42 ```
43
44 Note: This command is unaware of workspaces.
45
46 ### Description
47
48 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/v11/using-npm/config)).
49
50 When you run `npm login`, the CLI automatically generates a legacy token of `publish` type. For more information, see [About legacy tokens](/about-access-tokens#about-legacy-tokens).
51
52 When using `legacy` for your `auth-type`, the username and password, are read in from prompts.
53
54 To reset your password, go to [https://www.npmjs.com/forgot](https://www.npmjs.com/forgot)
55
56 To change your email address, go to [https://www.npmjs.com/email-edit](https://www.npmjs.com/email-edit)
57
58 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.
59
60 ### Configuration
61
62 #### `registry`
63
64 - Default: "https://registry.npmjs.org/"
65 - Type: URL
66
67 The base URL of the npm registry.
68
69 #### `scope`
70
71 - Default: the scope of the current project, if any, or ""
72 - Type: String
73
74 Associate an operation with a scope for a scoped registry.
75
76 Useful when logging in to or out of a private registry:
77
78 ```
79 # log in, linking the scope to the custom registry
80 npm login --scope=@mycorp --registry=https://registry.mycorp.com
81
82 # log out, removing the link and the auth token
83 npm logout --scope=@mycorp
84 ```
85
86 This will cause `@mycorp` to be mapped to the registry for future installation of packages specified according to the pattern `@mycorp/package`.
87
88 This will also cause `npm init` to create a scoped package.
89
90 ```
91 # accept all defaults, and create a package named "@foo/whatever",
92 # instead of just named "whatever"
93 npm init --scope=@foo --yes
94 ```
95
96 #### `auth-type`
97
98 - Default: "web"
99 - Type: "legacy" or "web"
100
101 What authentication strategy to use with `login`. Note that if an `otp` config is given, this value will always be set to `legacy`.
102
103 ### See Also
104
105 - [npm registry](/cli/v11/using-npm/registry)
106 - [npm config](/cli/v11/commands/npm-config)
107 - [npmrc](/cli/v11/configuring-npm/npmrc)
108 - [npm owner](/cli/v11/commands/npm-owner)
109 - [npm whoami](/cli/v11/commands/npm-whoami)
110 - [npm token](/cli/v11/commands/npm-token)
111 - [npm profile](/cli/v11/commands/npm-profile)