npm-login.1 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. .TH "NPM-LOGIN" "1" "March 2026" "NPM@11.12.0" ""
  2. .SH "NAME"
  3. \fBnpm-login\fR - Login to a registry user account
  4. .SS "Synopsis"
  5. .P
  6. .RS 2
  7. .nf
  8. npm login
  9. .fi
  10. .RE
  11. .P
  12. Note: This command is unaware of workspaces.
  13. .SS "Description"
  14. .P
  15. Verify a user in the specified registry, and save the credentials to the \fB.npmrc\fR file. If no registry is specified, the default registry will be used (see npm help config).
  16. .P
  17. When you run \fBnpm login\fR, the CLI automatically generates a legacy token of \fBpublish\fR type. For more information, see \fBAbout legacy tokens\fR \fI\(la/about-access-tokens#about-legacy-tokens\(ra\fR.
  18. .P
  19. When using \fBlegacy\fR for your \fBauth-type\fR, the username and password, are read in from prompts.
  20. .P
  21. To reset your password, go to \fI\(lahttps://www.npmjs.com/forgot\(ra\fR
  22. .P
  23. To change your email address, go to \fI\(lahttps://www.npmjs.com/email-edit\(ra\fR
  24. .P
  25. 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.
  26. .SS "Configuration"
  27. .SS "\fBregistry\fR"
  28. .RS 0
  29. .IP \(bu 4
  30. Default: "https://registry.npmjs.org/"
  31. .IP \(bu 4
  32. Type: URL
  33. .RE 0
  34. .P
  35. The base URL of the npm registry.
  36. .SS "\fBscope\fR"
  37. .RS 0
  38. .IP \(bu 4
  39. Default: the scope of the current project, if any, or ""
  40. .IP \(bu 4
  41. Type: String
  42. .RE 0
  43. .P
  44. Associate an operation with a scope for a scoped registry.
  45. .P
  46. Useful when logging in to or out of a private registry:
  47. .P
  48. .RS 2
  49. .nf
  50. # log in, linking the scope to the custom registry
  51. npm login --scope=@mycorp --registry=https://registry.mycorp.com
  52. # log out, removing the link and the auth token
  53. npm logout --scope=@mycorp
  54. .fi
  55. .RE
  56. .P
  57. This will cause \fB@mycorp\fR to be mapped to the registry for future installation of packages specified according to the pattern \fB@mycorp/package\fR.
  58. .P
  59. This will also cause \fBnpm init\fR to create a scoped package.
  60. .P
  61. .RS 2
  62. .nf
  63. # accept all defaults, and create a package named "@foo/whatever",
  64. # instead of just named "whatever"
  65. npm init --scope=@foo --yes
  66. .fi
  67. .RE
  68. .SS "\fBauth-type\fR"
  69. .RS 0
  70. .IP \(bu 4
  71. Default: "web"
  72. .IP \(bu 4
  73. Type: "legacy" or "web"
  74. .RE 0
  75. .P
  76. What authentication strategy to use with \fBlogin\fR. Note that if an \fBotp\fR config is given, this value will always be set to \fBlegacy\fR.
  77. .SS "See Also"
  78. .RS 0
  79. .IP \(bu 4
  80. npm help registry
  81. .IP \(bu 4
  82. npm help config
  83. .IP \(bu 4
  84. npm help npmrc
  85. .IP \(bu 4
  86. npm help owner
  87. .IP \(bu 4
  88. npm help whoami
  89. .IP \(bu 4
  90. npm help token
  91. .IP \(bu 4
  92. npm help profile
  93. .RE 0