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:
- Open the job’s configuration page.
- In the Configure
view, click the Before Build tab.
- Click Add Before Build Action, select NPM Registry Connection, and make sure that the build action is Enabled.
- 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.
- 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.
- To add NPM commands that use the NPM registry connection and run when
the job is executed:
- Select the Steps tab in the job configuration page.
- Click the Add Step dropdown.
- Select Common Build Tools, and then select Unix Shell.
- Specify the NPM command to run, for example
npm install --verbose
, in that step.
- Click Save.