Skip to main content
Harness Artifact Registry provides full support for npm packages, allowing you to host private JavaScript and TypeScript packages.

Overview

NPM registry features:
  • Standard npm registry protocol
  • Automatic metadata extraction from package.json
  • Scoped package support (@org/package)
  • Version management and dist-tags
  • Seamless integration with npm, yarn, and pnpm

Pushing npm packages

Use the hc artifact push npm command to publish packages:
hc artifact push npm <registry-name> <npm-tgz-path> \
  --pkg-url <pkg-url>

How it works

The CLI automatically:
  1. Validates the .tgz tarball format
  2. Extracts package.json from the tarball
  3. Reads package name and version from package.json
  4. Builds the npm upload payload
  5. Uploads the package to the registry
1

Create package tarball

Build your npm package:
# In your package directory
npm pack
# Creates: your-package-1.0.0.tgz
2

Upload to registry

Push the tarball:
hc artifact push npm my-npm-registry ./your-package-1.0.0.tgz \
  --pkg-url https://app.harness.io/registry/pkg
3

Configure npm client

Set up npm to use your registry:
hc registry configure npm my-npm-registry

Installing npm packages

After configuring your npm client, install packages as usual:
# Install from your private registry
npm install your-package

# Or with yarn
yarn add your-package

# Or with pnpm
pnpm add your-package

Registry configuration

Configure npm to use your Harness registry:

Project-level configuration

Create .npmrc in your project:
.npmrc
registry=https://<registry-url>/
//registry-url/:_authToken=<your-harness-token>

Scoped packages

For scoped packages (@myorg/package):
.npmrc
@myorg:registry=https://<registry-url>/
//registry-url/:_authToken=<your-harness-token>

Using the CLI

Automate configuration with:
hc registry configure npm my-npm-registry \
  --scope @myorg \
  --project

Examples

# Pack and push a public package
npm pack
hc artifact push npm my-registry ./mypackage-1.0.0.tgz \
  --pkg-url https://app.harness.io/registry/pkg

Package.json requirements

The package.json must contain both name and version fields
Minimal package.json:
{
  "name": "mypackage",
  "version": "1.0.0",
  "description": "My awesome package",
  "main": "index.js"
}
For scoped packages:
{
  "name": "@myorg/mypackage",
  "version": "1.0.0"
}

CI/CD integration

- name: Publish to Harness
  env:
    HARNESS_API_KEY: ${{ secrets.HARNESS_API_KEY }}
  run: |
    npm pack
    hc artifact push npm my-registry ./*.tgz \
      --pkg-url https://app.harness.io/registry/pkg

Troubleshooting

Ensure your tarball was created correctly:
# Check tarball contents
tar -tzf mypackage-1.0.0.tgz | grep package.json

# Verify package.json has name and version
npm pack --dry-run
The file must be a valid gzipped tarball:
# Create proper tarball
npm pack  # Don't use tar directly
Check authentication and permissions:
hc auth status
hc registry list  # Verify registry exists

See also

Build docs developers (and LLMs) love