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/v10/cli-commands/login
18 - /cli-documentation/v10/cli-commands/npm-login
19 - /cli-documentation/v10/commands/login
20 - /cli-documentation/v10/commands/npm-login
21 - /cli-documentation/v10/login
22 - /cli-documentation/v10/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/v10/cli-commands/login
30 - /cli/v10/cli-commands/npm-login
31 - /cli/v10/commands/login
32 - /cli/v10/login
33 - /cli/v10/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/v10/using-npm/config)).
49
50 When using `legacy` for your `auth-type`, the username and password, are read in from prompts.
51
52 To reset your password, go to [https://www.npmjs.com/forgot](https://www.npmjs.com/forgot)
53
54 To change your email address, go to [https://www.npmjs.com/email-edit](https://www.npmjs.com/email-edit)
55
56 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.
57
58 ### Configuration
59
60 #### `registry`
61
62 - Default: "https://registry.npmjs.org/"
63 - Type: URL
64
65 The base URL of the npm registry.
66
67 #### `scope`
68
69 - Default: the scope of the current project, if any, or ""
70 - Type: String
71
72 Associate an operation with a scope for a scoped registry.
73
74 Useful when logging in to or out of a private registry:
75
76 ```
77 # log in, linking the scope to the custom registry
78 npm login --scope=@mycorp --registry=https://registry.mycorp.com
79
80 # log out, removing the link and the auth token
81 npm logout --scope=@mycorp
82 ```
83
84 This will cause `@mycorp` to be mapped to the registry for future installation of packages specified according to the pattern `@mycorp/package`.
85
86 This will also cause `npm init` to create a scoped package.
87
88 ```
89 # accept all defaults, and create a package named "@foo/whatever",
90 # instead of just named "whatever"
91 npm init --scope=@foo --yes
92 ```
93
94 #### `auth-type`
95
96 - Default: "web"
97 - Type: "legacy" or "web"
98
99 What authentication strategy to use with `login`. Note that if an `otp` config is given, this value will always be set to `legacy`.
100
101 ### See Also
102
103 - [npm registry](/cli/v10/using-npm/registry)
104 - [npm config](/cli/v10/commands/npm-config)
105 - [npmrc](/cli/v10/configuring-npm/npmrc)
106 - [npm owner](/cli/v10/commands/npm-owner)
107 - [npm whoami](/cli/v10/commands/npm-whoami)
108 - [npm token](/cli/v10/commands/npm-token)
109 - [npm profile](/cli/v10/commands/npm-profile)