11cb0ef41Sopenharmony_ci--- 21cb0ef41Sopenharmony_cititle: npm-login 31cb0ef41Sopenharmony_cisection: 1 41cb0ef41Sopenharmony_cidescription: Login to a registry user account 51cb0ef41Sopenharmony_ci--- 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci### Synopsis 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci```bash 101cb0ef41Sopenharmony_cinpm login 111cb0ef41Sopenharmony_ci``` 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciNote: This command is unaware of workspaces. 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci### Description 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciVerify a user in the specified registry, and save the credentials to the 181cb0ef41Sopenharmony_ci`.npmrc` file. If no registry is specified, the default registry will be 191cb0ef41Sopenharmony_ciused (see [`config`](/using-npm/config)). 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciWhen using `legacy` for your `auth-type`, the username and password, are 221cb0ef41Sopenharmony_ciread in from prompts. 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciTo reset your password, go to <https://www.npmjs.com/forgot> 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciTo change your email address, go to <https://www.npmjs.com/email-edit> 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciYou may use this command multiple times with the same user account to 291cb0ef41Sopenharmony_ciauthorize on a new machine. When authenticating on a new machine, 301cb0ef41Sopenharmony_cithe username, password and email address must all match with 311cb0ef41Sopenharmony_ciyour existing record. 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci### Configuration 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci#### `registry` 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci* Default: "https://registry.npmjs.org/" 381cb0ef41Sopenharmony_ci* Type: URL 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ciThe base URL of the npm registry. 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci#### `scope` 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci* Default: the scope of the current project, if any, or "" 471cb0ef41Sopenharmony_ci* Type: String 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciAssociate an operation with a scope for a scoped registry. 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ciUseful when logging in to or out of a private registry: 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci``` 541cb0ef41Sopenharmony_ci# log in, linking the scope to the custom registry 551cb0ef41Sopenharmony_cinpm login --scope=@mycorp --registry=https://registry.mycorp.com 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci# log out, removing the link and the auth token 581cb0ef41Sopenharmony_cinpm logout --scope=@mycorp 591cb0ef41Sopenharmony_ci``` 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_ciThis will cause `@mycorp` to be mapped to the registry for future 621cb0ef41Sopenharmony_ciinstallation of packages specified according to the pattern 631cb0ef41Sopenharmony_ci`@mycorp/package`. 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_ciThis will also cause `npm init` to create a scoped package. 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci``` 681cb0ef41Sopenharmony_ci# accept all defaults, and create a package named "@foo/whatever", 691cb0ef41Sopenharmony_ci# instead of just named "whatever" 701cb0ef41Sopenharmony_cinpm init --scope=@foo --yes 711cb0ef41Sopenharmony_ci``` 721cb0ef41Sopenharmony_ci 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ci#### `auth-type` 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ci* Default: "web" 781cb0ef41Sopenharmony_ci* Type: "legacy" or "web" 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ciWhat authentication strategy to use with `login`. Note that if an `otp` 811cb0ef41Sopenharmony_ciconfig is given, this value will always be set to `legacy`. 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci 841cb0ef41Sopenharmony_ci 851cb0ef41Sopenharmony_ci### See Also 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ci* [npm registry](/using-npm/registry) 881cb0ef41Sopenharmony_ci* [npm config](/commands/npm-config) 891cb0ef41Sopenharmony_ci* [npmrc](/configuring-npm/npmrc) 901cb0ef41Sopenharmony_ci* [npm owner](/commands/npm-owner) 911cb0ef41Sopenharmony_ci* [npm whoami](/commands/npm-whoami) 921cb0ef41Sopenharmony_ci* [npm token](/commands/npm-token) 931cb0ef41Sopenharmony_ci* [npm profile](/commands/npm-profile) 94