Creating and publishing an organization scoped package

As an organization member, you can create and publish public and private packages within the organization's scope.

Creating an organization scoped package

  1. On the command line, make a directory with the name of the package you would like to create.

    mkdir /path/to/package/directory
  2. Navigate to the newly-created package directory.

  3. To create an organization scoped package, on the command line, run:

    npm init --scope=<your_org_name>
  4. To verify the package is using your organization scope, in a text editor, open the package's package.json file and check that the name is @your_org_name/<pkg_name>, replacing your_org_name with the name of your organization.

Publishing a private organization scoped package

By default, npm publish will publish a scoped package as private.

By default, any scoped package is published as private. However, if you have an organization that does not have the Private Packages feature, npm publish will fail unless you pass the access flag.

  1. On the command line, navigate to the package directory.

  2. Run npm publish.

Private packages will say private below the package name on the npm website.

Screenshot of a private npm Teams package

Publishing a public organization scoped package

To publish an organization scoped package as public, use npm publish --access public.

  1. On the command line, navigate to the package directory.

  2. Run npm publish --access public.

Public packages will say public below the package name on the npm website.

Screenshot of a public npm Teams package
Edit this page on GitHub
1 contributormona
Last edited by mona on March 21, 2023
声明:npm 及相关 logo 的版权归 npmjs.com 所有。本站点仅用于 npm 中文文档,与 npmjs.com 没有任何关系。由于译者水平有限,且避免产生误解,条款和政策内容不进行翻译,关于这部分,请移步官网查看最新内容。