JetBrains Space Help

Publish npm Packages

Let's assume you have an npm package and want to publish it to the newly created npm registry using:

Note that publishing packages with the same package version is not allowed. The server will return the 409 HTTP response.

Publish packages using npm command-line tool

  1. Log in to the npm registry:

    npm login --registry https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm

    • https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm is the registry URL

    • mycompany is the name of your company in Space, mynpm is the registry name.

    If you are not sure about the URL, you can copy the URL of a particular npm registry on the Packages page.

  2. When asked for credentials, specify your Space username and password. npm uses permanent tokens for authentication. Once you log in to the registry, Space will automatically create a permanent token specifically for accessing the npm registry. This token will be saved in your local .npmrc configuration file and used for all further connections to the specified registry. You can manage the created token on the My Profile | Security | Personal Tokens page.

    Automatically generated token for an npm registry
  3. Open the directory containing the package you want to publish.

  4. Publish the package to the registry:

    npm publish --registry https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm

Publish npm packages from JetBrains TeamCity

Prerequisites: You have a working build configuration in TeamCity that creates a package. Your task is to publish this package to a Space Packages registry.

  1. In Space, create an application account that you will use for connecting to Space from TeamCity.

  2. Connect the TeamCity instance to the Packages registry where you want publish packages. In TeamCity:

    • in project properties, choose Connection | Add Connection,

    • in the connection settings, specify the URL of the npm registry (it should look like https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm) and the application permanent token.

    TeamCity. Add npm registry
  3. Add the npm registry connection to your TeamCity build configuration: In the build configuration settings, choose Build Features | Add build feature.

  4. In the Add Build Feature window:

    • choose NPM Registry Connection,

    • in Choose connection, choose the connection you have created in step 1.

    TeamCity. Add npm registry connection
  5. In your build configuration, add a build step that publishes a package. For example, a step with the Node.js runner type that runs:

    npm config set init.version 0.0.%build.number% npm init -y npm publish --registry https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm

Publish npm packages from Space Automation

For the instructions on how to publish npm packages from Space Automation, refer to Space Automation examples.

Last modified: 08 November 2021