你可以从网站或命令行更改范围包的可见性。

You can change the visibility of a scoped package from the website or command line.

你必须是拥有包的用户账户或组织的所有者才能更改包的可见性。

You must be the owner of the user account or organization that owns the package in order to change package visibility.

有关包可见性的更多信息,请参阅“包的范围、访问级别和可见性”。

For more information about package visibility, see "Package scope, access level, and visibility".

注意:你无法更改无范围包的可见性。只有付费订阅的范围包可能是私有的。

Note: You cannot change the visibility of an unscoped package. Only scoped packages with a paid subscription may be private.

将公共包设为私有

Making a public package private

注意:将包设为私有需要付费用户账户或组织。要注册付费用户或组织,请转到 https://www.npmjs.com/settings/account-name/billing,将 account-name 替换为你的 npm 用户账户或组织的名称。

Note: Making a package private requires a paid user account or organization. To sign up for a paid user or organization, go to https://www.npmjs.com/settings/account-name/billing, replacing account-name with the name of your npm user account or organization.

如果你想限制你拥有的公共包的访问和可见性,你可以将包设为私有。当你将包设为私有时,其访问权限将立即更新,并在更改后的几分钟内从网站上删除。

If you want to restrict access and visibility for a public package you own, you can make the package private. When you make a package private, its access will be updated immediately and it will be removed from the website within a few minutes of the change.

使用网站

Using the website

  1. npm 网站 上,跳转到包页面。

    On the npm website, go to the package page.

  2. 在包页面上,单击“设置”。

    On the package page, click Settings.

  3. 在 "包访问" 下,选择 "包是私有的吗?"

    Under "Package Access", select "Is Package Private?"

  4. 单击更新包设置。

    Click Update package settings.

使用命令行

Using the command line

要在命令行上将公共包设为私有,请运行以下命令,将 <package-name> 替换为你的包的名称:

To make a public package private on the command line, run the following command, replacing <package-name> with the name of your package:

npm access restricted <package-name>

有关详细信息,请参阅 npm access 文档。

For more information, see the npm access documentation.

将私有包设为公共

Making a private package public

注意:当你公开一个私有包时,所有 npm 用户都可以看到和下载该包。

Note: When you make a private package public, the package will be visible to and downloadable by all npm users.

使用网站

Using the website

  1. 在 npm 网站上,跳转到包页面。

    On the npm website, go to the package page.

  2. 在包页面上,单击“设置”。

    On the package page, click Settings.

  3. 在 "包访问" 下,取消选择 "包是私有的吗?"

    Under "Package Access", deselect "Is Package Private?"

  4. 单击更新包设置。

    Click Update package settings.

使用命令行

Using the command line

要在命令行上公开私有包,请运行以下命令,将 <package-name> 替换为你的包的名称:

To make a private package public on the command line, run the following command, replacing <package-name> with the name of your package:

npm access public <package-name>

有关详细信息,请参阅 npm access CLI 文档

For more information, see the npm access CLI documentation.

npm 中文网 - 粤ICP备13048890号