Configure a Job to Connect to the NPM Registry

You can use a predefined connection to set up a job to connect to the project's NPM registry or to an external NPM registry:

  1. Open the job’s configuration page.
  2. In the Configure Configure view icon view, click the Before Build tab.
  3. Click Add Before Build Action, select NPM Registry Connection, and make sure that the build action is Enabled.
  4. Select the registry to use:
    • To access scoped or unscoped packages in your project's private NPM registry, select the Use project's NPM registry checkbox and the URL will be populated automatically.

      If you want the build to use the project's custom configuration file (.npmrc), specify its path (for example, path/to/my/project/.npmrc) in the Custom .npmrc field.

    • To access packages in an external NPM registry, select the Use External NPM registry checkbox, set the toggle to Use existing connection, and select a pre-defined connection from the dropdown, if your project owner has created a connection. (If a pre-defined connection isn’t available, you won't be able to set one up from this page so you'll need to contact your project owner to define a connection for you to use.) Once the registry has been selected, the configured registry URL and the credentials are displayed in the read-only fields.

      If you want the build to use the project's custom configuration file (.npmrc), specify its path (for example, path/to/my/project/.npmrc) in the Custom .npmrc field.

  5. To add NPM commands that use the NPM registry connection and run when the job is executed:
    1. Select the Steps tab in the job configuration page.
    2. Click the Add Step dropdown.
    3. Select Common Build Tools, and then select Unix Shell.
    4. Specify the NPM command to run, for example npm install --verbose, in that step.
  6. Click Save.