JetBrains Space Help

Use an npm Registry with npmjs.com

The npm client is able to work with only one registry at a time: It is not possible to simultaneously use both npmjs.com and a Space Packages nmp registry. To avoid this limitation, we recommend that you use scoped npm packages. Typically, this npm feature is used to group packages together and separate private and public packages. After you assign @somescope to a package, this scope will be added to the package name, e.g. @somescope/somepackagename. If another user or company publishes their own somepackagename to npmjs.com, there will be no conflicts. An additional feature of scoped packages is the ability to assign scopes to registries. For example, after you assign @somescope to a particular registry (e.g. a registry in Packages), all packages marked with @somescope will be published to/installed from this registry only. For other packages, npm will use the default registry (npmjs.com).

To assign a scope to an npm registry

  1. Make sure you are logged in to the desired Packages npm registry.

  2. Run the npm config command. For example:

    npm config set @somescope:registry https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm

After this, all scoped packages will be associated with this registry.

To publish a scoped package to an npm registry

  1. Make sure the package you want to publish has a scope assigned. For example, if you need to assign a scope in an existing package, open the corresponding package.json and add the scope to name. For example: "name": "@somescope/myfirstnpmpackage". If you are creating a new package, you can use the npm init --scope=somescope command.

  2. Open the directory containing the package.

  3. Run

    npm publish

To install such a package, run:

npm install @somescope/myfirstnpmpackage
Last modified: 14 July 2020