npm Repositories in JFrog Artifactory¶
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¶
- Go to Administration โ Repositories โ + New Repository
- Select Local
- Choose npm
- Set Repository Key:
npm-local - Click Create Local Repository
Step 2: Create a Remote Repository โ npmjs.org Proxy¶
- Go to Administration โ Repositories โ + New Repository
- Select Remote
- Choose npm
- Set Repository Key:
npmjs-remote - Set URL:
https://registry.npmjs.org - Click Create Remote Repository
Step 3: Create a Virtual Repository¶
- Go to Administration โ Repositories โ + New Repository
- Select Virtual
- Choose npm
- Set Repository Key:
npm-virtual - Add repositories:
npm-localnpmjs-remote- Set Default Deployment Repository:
npm-local - 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/
Option C: Use JFrog CLI to configure (recommended for CI)¶
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