1--- 2title: npm-login 3section: 1 4description: Login to a registry user account 5--- 6 7### Synopsis 8 9```bash 10npm login 11``` 12 13Note: This command is unaware of workspaces. 14 15### Description 16 17Verify a user in the specified registry, and save the credentials to the 18`.npmrc` file. If no registry is specified, the default registry will be 19used (see [`config`](/using-npm/config)). 20 21When using `legacy` for your `auth-type`, the username and password, are 22read in from prompts. 23 24To reset your password, go to <https://www.npmjs.com/forgot> 25 26To change your email address, go to <https://www.npmjs.com/email-edit> 27 28You may use this command multiple times with the same user account to 29authorize on a new machine. When authenticating on a new machine, 30the username, password and email address must all match with 31your existing record. 32 33### Configuration 34 35#### `registry` 36 37* Default: "https://registry.npmjs.org/" 38* Type: URL 39 40The base URL of the npm registry. 41 42 43 44#### `scope` 45 46* Default: the scope of the current project, if any, or "" 47* Type: String 48 49Associate an operation with a scope for a scoped registry. 50 51Useful when logging in to or out of a private registry: 52 53``` 54# log in, linking the scope to the custom registry 55npm login --scope=@mycorp --registry=https://registry.mycorp.com 56 57# log out, removing the link and the auth token 58npm logout --scope=@mycorp 59``` 60 61This will cause `@mycorp` to be mapped to the registry for future 62installation of packages specified according to the pattern 63`@mycorp/package`. 64 65This will also cause `npm init` to create a scoped package. 66 67``` 68# accept all defaults, and create a package named "@foo/whatever", 69# instead of just named "whatever" 70npm init --scope=@foo --yes 71``` 72 73 74 75#### `auth-type` 76 77* Default: "web" 78* Type: "legacy" or "web" 79 80What authentication strategy to use with `login`. Note that if an `otp` 81config is given, this value will always be set to `legacy`. 82 83 84 85### See Also 86 87* [npm registry](/using-npm/registry) 88* [npm config](/commands/npm-config) 89* [npmrc](/configuring-npm/npmrc) 90* [npm owner](/commands/npm-owner) 91* [npm whoami](/commands/npm-whoami) 92* [npm token](/commands/npm-token) 93* [npm profile](/commands/npm-profile) 94