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/v10
7 github_path: docs/lib/content/commands/npm-login.md
8 redirect_from:
9 - /cli-documentation/v10/cli-commands/login
10 - /cli-documentation/v10/cli-commands/npm-login
11 - /cli-documentation/v10/commands/login
12 - /cli-documentation/v10/commands/npm-login
13 - /cli-documentation/v10/login
14 - /cli-documentation/v10/npm-login
15 - /cli/v10/cli-commands/login
16 - /cli/v10/cli-commands/npm-login
17 - /cli/v10/commands/login
18 - /cli/v10/login
19 - /cli/v10/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/v10/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/v10/using-npm/registry)
88 - [npm config](/cli/v10/commands/npm-config)
89 - [npmrc](/cli/v10/configuring-npm/npmrc)
90 - [npm owner](/cli/v10/commands/npm-owner)
91 - [npm whoami](/cli/v10/commands/npm-whoami)
92 - [npm token](/cli/v10/commands/npm-token)
93 - [npm profile](/cli/v10/commands/npm-profile)