registry

JavaScript 包注册表

选择命令行版本:

描述

🌐 Description

为了按名称和版本解析包,npm 与实现 CommonJS 包注册表规范的注册表网站进行对话,以读取包信息。

🌐 To resolve packages by name and version, npm talks to a registry website that implements the CommonJS Package Registry specification for reading package info.

npm 默认配置为使用 https://registry.npmjs.orgnpm 公共注册表。使用 npm 公共注册表需遵守 https://npm.nodejs.cn/policies/terms 上的使用条款。

🌐 npm is configured to use the npm public registry at https://registry.npmjs.org by default. Use of the npm public registry is subject to terms of use available at https://npm.nodejs.cn/policies/terms.

你可以配置 npm 使用你喜欢的任何兼容注册表,甚至可以运行你自己的注册表。使用他人的注册表可能需要遵守他们的使用条款。

🌐 You can configure npm to use any compatible registry you like, and even run your own registry. Use of someone else's registry may be governed by their terms of use.

npm 的包注册表实现也支持多个写入 API,以允许发布包和管理用户账户信息。

🌐 npm's package registry implementation supports several write APIs as well, to allow for publishing packages and managing user account information.

使用的注册表 URL 取决于包的作用域(参见 scope)。如果未指定作用域,则使用默认注册表,该注册表由 registry 配置 参数提供。有关 npm 配置管理的更多信息,请参见 npm confignpmrcconfig。身份验证配置,例如身份验证令牌和证书,是针对单个注册表特定作用域配置的。请参见 身份验证相关配置

🌐 The registry URL used is determined by the scope of the package (see scope. If no scope is specified, the default registry is used, which is supplied by the registry config parameter. See npm config, npmrc, and config for more on managing npm's configuration. Authentication configuration such as auth tokens and certificates are configured specifically scoped to an individual registry. See Auth Related Configuration

当在 package-lock 或 shrinkwrap 中使用默认注册表时,它具有“当前配置的注册表”的特殊含义。如果你在使用默认注册表时创建锁文件,你可以切换到其他注册表,npm 将从新的注册表安装软件包,但如果你在使用自定义注册表时创建锁文件,即使你切换到另一个注册表,软件包仍会从该自定义注册表安装。

🌐 When the default registry is used in a package-lock or shrinkwrap it has the special meaning of "the currently configured registry". If you create a lock file while using the default registry you can switch to another registry and npm will install packages from the new registry, but if you create a lock file while using a custom registry packages will be installed from that registry even after you change to another registry.

npm 是否会将有关我的任何信息发送回注册表?

🌐 Does npm send any information about me back to the registry?

是的。

🌐 Yes.

当向注册表触发请求时,npm 会添加两个标头,其中包含有关你的环境的信息:

🌐 When making requests of the registry npm adds two headers with information about your environment:

  • Npm-Scope – 如果你的项目有范围,此标题将包含其范围。未来,npm 希望构建使用此信息的注册表功能,以便你可以为组织自定义体验。
  • Npm-In-CI – 如果 npm 认为此安装正在连续集成环境中运行,则设置为“true”,否则为“false”。这是通过检查以下环境变量来检测的:CITDDIUMJENKINS_URLbamboo.buildKey。如果你想了解更多信息,你可能会觉得原始 PR很有趣。此功能用于收集关于 npm 如何被人类使用的更好指标,与构建服务器相比。

npm 注册表不会尝试将这些标头中的信息与可能在相同请求中使用的任何经过身份验证的账户相关联。

🌐 The npm registry does not try to correlate the information in these headers with any authenticated accounts that may be used in the same requests.

如何防止我的包被发布到官方注册表

🌐 How can I prevent my package from being published in the official registry?

在你的 package.json 中设置 "private": true 以完全阻止其发布,或设置 "publishConfig":{"registry":"http://my-internal-registry.local"} 以强制仅发布到你的内部/私有注册表。

🌐 Set "private": true in your package.json to prevent it from being published at all, or "publishConfig":{"registry":"http://my-internal-registry.local"} to force it to be published only to your internal/private registry.

有关 package.json 文件中内容的更多信息,请参见 package.json

🌐 See package.json for more info on what goes in the package.json file.

我在哪里可以找到我(和其他人)发布的包?

🌐 Where can I find my (and others') published packages?

https://www.npmjs.com/

也可以看看

🌐 See also