选择命令行版本:
🌐 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.org 的 npm 公共注册表。使用 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 config、npmrc 和 config。认证配置(如认证令牌和证书)是针对特定注册表单独配置的。请参阅 认证相关配置
🌐 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 中使用默认注册表时,它有“当前配置的注册表”的特殊含义。如果你在使用默认注册表时创建了锁文件,你可以切换到另一个注册表,npm 会从新的注册表安装包;但如果你在使用自定义注册表时创建了锁文件,即使之后换到另一个注册表,包也会从原来的自定义注册表安装。
🌐 When the default registry is used in a package-lock 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.
🌐 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”。这是通过检查以下环境变量来检测的:CI、TDDIUM、JENKINS_URL、bamboo.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?
🌐 See also