npm-logout

注销注册表

选择命令行版本:

概要

🌐 Synopsis

npm logout

注意:此命令不支持工作区。

🌐 Note: This command is unaware of workspaces.

描述

🌐 Description

当登录到支持基于令牌的身份验证的注册表时,告诉服务器结束该令牌的会话。这将使你在任何地方使用的令牌失效,而不仅仅是当前环境中。

🌐 When logged into a registry that supports token-based authentication, tell the server to end this token's session. This will invalidate the token everywhere you're using it, not just for the current environment.

当登录使用用户名和密码认证的旧版注册表时,这将清除用户配置中的凭据。在这种情况下,它将仅影响当前环境。

🌐 When logged into a legacy registry that uses username and password authentication, this will clear the credentials in your user configuration. In this case, it will only affect the current environment.

如果提供了 --scope,这将查找与该作用域连接的注册表的凭据(如果已设置)。

🌐 If --scope is provided, this will find the credentials for the registry connected to that scope, if set.

配置

🌐 Configuration

registry

  • 默认: "https://registry.npmjs.org/"
  • 类型:网址

npm 注册表的基本 URL。

🌐 The base URL of the npm registry.

scope

  • 默认:当前项目的范围(如果有)或
  • 类型:字符串

将操作与范围注册表的作用域相关联。

🌐 Associate an operation with a scope for a scoped registry.

在登录或退出私有注册表时很有用:

🌐 Useful when logging in to or out of a private registry:

# log in, linking the scope to the custom registry
npm login --scope=@mycorp --registry=https://registry.mycorp.com
# log out, removing the link and the auth token
npm logout --scope=@mycorp

这将导致 @mycorp 被映射到注册表中,以便将来根据模式 @mycorp/package 指定的软件包进行安装。

🌐 This will cause @mycorp to be mapped to the registry for future installation of packages specified according to the pattern @mycorp/package.

这也将导致 npm init 创建一个带作用域的包。

🌐 This will also cause npm init to create a scoped package.

# accept all defaults, and create a package named "@foo/whatever",
# instead of just named "whatever"
npm init --scope=@foo --yes

也可以看看

🌐 See Also