JetBrains Space Help

Publish npm Packages

Suppose 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 packages using Yarn 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.

  3. Configure the registry to require authentication:

    npm config set //npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm:always-auth true

  4. Open the directory containing the package you want to publish.

  5. Publish the package to the registry:

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

Publish packages using Unity

  1. Generate a personal token.

  2. Add a registry connection to the .upmconfig.toml file:

    [npmAuth."https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm"] token = TOKEN_GOES_HERE email = EMAIL_ADDRESS alwaysAuth = true

  3. Create a custom package that includes a manifest file. Navigate to the directory that contains the package.json file and publish it using npm or yarn.

Publish packages using pnpm command-line tool

  1. Log in to the npm registry:

    pnpm 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.

  3. Configure the registry to require authentication:

    pnpm config set //npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm:always-auth true

  4. Open the directory containing the package you want to publish.

  5. Publish the package to the registry:

    pnpm 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 to 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: 23 November 2022