Skip to content

npm Repositories in JFrog Artifactory

โ† Back to JFrog Tutorials


JFrog Artifactory is a fully compliant npm registry. It can host your private npm packages, proxy the public npm registry, and expose everything through a single virtual registry URL โ€” giving your JavaScript/Node.js teams a consistent and reliable package source.

All steps use JFrog SaaS at https://<company>.jfrog.io.


What You'll Build

npm-local              [LOCAL]  โ†’ your team's private npm packages
npmjs-remote           [REMOTE] โ†’ proxy of https://registry.npmjs.org
npm-virtual            [VIRTUAL]โ†’ single registry URL for all devs

Step 1: Create a Local Repository

  1. Go to Administration โ†’ Repositories โ†’ + New Repository
  2. Select Local
  3. Choose npm
  4. Set Repository Key: npm-local
  5. Click Create Local Repository

Step 2: Create a Remote Repository โ€” npmjs.org Proxy

  1. Go to Administration โ†’ Repositories โ†’ + New Repository
  2. Select Remote
  3. Choose npm
  4. Set Repository Key: npmjs-remote
  5. Set URL: https://registry.npmjs.org
  6. Click Create Remote Repository

Step 3: Create a Virtual Repository

  1. Go to Administration โ†’ Repositories โ†’ + New Repository
  2. Select Virtual
  3. Choose npm
  4. Set Repository Key: npm-virtual
  5. Add repositories:
  6. npm-local
  7. npmjs-remote
  8. Set Default Deployment Repository: npm-local
  9. Click Create Virtual Repository

Step 4: Configure npm to Use JFrog SaaS

Option A: Set registry in .npmrc (per-project)

Create or update .npmrc in your project root:

registry=https://<company>.jfrog.io/artifactory/api/npm/npm-virtual/
//`<company>`.jfrog.io/artifactory/api/npm/npm-virtual/:_authToken=your-access-token

Option B: Set registry globally

npm config set registry https://<company>.jfrog.io/artifactory/api/npm/npm-virtual/
npm login --registry=https://<company>.jfrog.io/artifactory/api/npm/npm-virtual/
jf npmc --repo-resolve npm-virtual --repo-deploy npm-local --server-id my-jfrog-server

Step 5: Install Packages via JFrog

Once configured, npm install works exactly as before โ€” all traffic routes through Artifactory:

npm install express
npm install lodash@4.17.21

Artifactory fetches from npmjs-remote (proxy), caches, and returns. Subsequent installs are served from cache.


Step 6: Publish a Private Package to JFrog

In your package.json:

{
  "name": "@myorg/my-package",
  "version": "1.0.0",
  "publishConfig": {
    "registry": "https://<company>.jfrog.io/artifactory/api/npm/npm-local/"
  }
}

Publish:

npm publish

Repository Comparison Summary

Feature Local Remote Virtual
Store private packages โœ… โŒ โŒ
Proxy npm registry โŒ โœ… โŒ
Single URL for devs โŒ โŒ โœ…
Publish target โœ… โŒ Delegates to local
Install dependencies Private only Public only Both โœ…

Use Cases

Scenario Solution
Share private UI components between teams Publish to npm-local, install via npm-virtual
npm install react Served from npmjs-remote cache
npmjs.org is down CI still works โ€” packages cached in JFrog
One .npmrc config for all developers Point at npm-virtual โ€” resolves both public and private

Next Steps

๐Ÿ‘‰ PyPI Repositories ๐Ÿ‘‰ JFrog CLI Basics


๐Ÿง  Quick Quiz

#

Where should you point the registry field in .npmrc when using JFrog Artifactory?


๐Ÿ“ฌ DevopsPilot Weekly โ€” Learn DevOps, Cloud & Gen AI the simple way.
๐Ÿ‘‰ Subscribe here