Skip to main content

npm-quickstart

Last updated on

Prerequisites

  • Ensure you have the NPM CLI (npm) installed on your local machine.
  • Access to a Harness account with appropriate permissions to create registries and connectors.

Create a NPM Artifact Registry

private registry

This registry will serve as your private NPM registry within Harness.


Configure an Upstream Proxy (Optional)

An upstream proxy allows your registry to fetch NPM packages from external sources if they are not available locally.

Create an upstream proxy

Configure the upstream proxy in your registry

upstream proxy caching

If a NPM package isn’t found in your Harness registry, the upstream proxy fetches it from an external registry like NPM Central, reducing duplication and improving resolution.


Publish & Install NPM Packages

Authenticate the CLI with the Harness Registry

  1. In your Harness NPM Artifact Registry, click Setup Client.
  2. Create or update your ~/.npmrc file with the following content:
registry=https://pkg.harness.io/pkg/<account-id>/npm-registry/npm/
//pkg.harness.io/pkg/<account-id>/npm-registry/npm/:_authToken=<TOKEN>
  1. Click Generate Identity Token to generate a new token that serves as the password for uploading and downloading artifacts.

Publish a Package to the Registry

  1. Build and publish your package:
npm run build
npm publish

Install your package

  1. Install your package using npm:
npm install <ARTIFACT_NAME>@<VERSION>
usage

These commands upload or retrieve NPM packages between your local project and the Harness registry.