目录
目录
注意:你必须使用 npm 版本 2 或更高版本才能使用范围。要升级到最新版本的 npm,请在命令行上运行 npm install npm@latest -g
¥Note: You must be using npm version 2 or greater to use scopes. To upgrade to the latest version of npm, on the command line, run npm install npm@latest -g
当你注册 npm 用户账户或创建组织时,你将获得与你的用户或组织名称匹配的范围。你可以将此范围用作相关包的命名空间。
¥When you sign up for an npm user account or create an organization, you are granted a scope that matches your user or organization name. You can use this scope as a namespace for related packages.
范围允许你创建与其他用户或组织创建的包同名的包,而不会发生冲突。
¥A scope allows you to create a package with the same name as a package created by another user or organization without conflict.
当在 package.json
文件中列为依赖时,范围包的前面是它们的作用域名称。范围名称是 @
和斜杠之间的所有内容:
¥When listed as a dependent in a package.json
file, scoped packages are preceded by their scope name. The scope name is everything between the @
and the slash:
-
"npm" 范围:
¥**"npm" scope:**
@npm/package-name
-
"npmcorp" 范围:
¥**"npmcorp" scope:**
@npmcorp/package-name
要创建和发布公共范围的包,请参阅“创建和发布范围公共包”。
¥To create and publish public scoped packages, see "Creating and publishing scoped public packages".
要创建和发布私有范围的包,请参阅“创建和发布私有包”。
¥To create and publish private scoped packages, see "Creating and publishing private packages".