选择命令行版本:
🌐 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
registrynpm 注册表的基本 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 registrynpm login --scope=@mycorp --registry=https://registry.mycorp.com# log out, removing the link and the auth tokennpm 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