Artifactory (NPM)

3 Easy Steps

Teams using JFrog Artifactory can manage access to NES packages through 3 easy steps:

  1. Create a Remote Repository for our private NPM registry.
  2. Configure (or create) a Virtual Repository to leverage the newly created Remote Repository.
  3. Verify your developers are able to access our package through your Virtual Repository.

Create a Remote Repository

  1. Navigate to the Administration tab (top navbar next to Application) "Step 1"
  2. Select Repositories (left side navbar) "Step 2"
  3. Navigate to the Remote subtab. "Step 3"
  4. Select Create Repository > Remote, and then select NPM as the type. "Step 4a""Step 4b"
  5. Configure the following parameters on the Basic tab: "Step 5"
ParameterValue
Repository Keynes (or whatever alias your team prefers)
URLhttps://registry.nes.herodevs.com/npm/pkg
Usernameartifactory
Password<NES_ACCESS_TOKEN>
Include PatternsClick the X to delete the default glob **/* pattern
.npm/@neverendingsupport/**
@neverendingsupport/**
Remote Mapping Layoutnpm-default
  1. Configure the following on the Advanced tab:

"Step 6"

  • Ensure Bypass HEAD Requests is checked
  • Ensure Disable URL Normalization is checked

The final results should look similar to the following:

Basic

"Result-Basic"

Advanced

"Result-Advanced"

Configure a Virtual Repository

In this step, you should configure the virtual repository referenced in the .npmrc files. This step is fairly straight forward, and only requires adding our private NPM registry after the public npmjs.org registry.

If you do not have a Remote Repository configured for npmjs.org

Create a Remote repository with below parameters. Leave the rest of the default set up as is.

ParameterValue
Repository Keynpm-remote
URLhttps://registry.npmjs.org

The result of creating a Remote repository for npmjs.org should look like the following screenshot. "Result-Advanced"

If you do not have a Virtual Repository configured with npm-remote

Follow the steps below to create a new Virtual Repository. If you already have a Virtual Repository created, you can skip this step and proceed to configuring the Virtual Repository.

  1. Navigate to the Administration tab "Step 1"
  2. Select Repositories"Step 2"
  3. Navigate to Virtual subtab "Step 3"
  4. Select Create Repository > Virtual"Step 4"

Configure the Virtual Repository

The following configuration is required to ensure that Artifactory will properly route requests to our private NPM registry.

The checklist below lists the required configuration for the Virtual Repository.

  • Ensure "npm-remote" is included in the Selected Repositories section
  • Ensure "nes" is included in the Selected Repositories section
  • Ensure "nes" is at the bottom of the list

To verify the configuration, in most versions of Artifactory, you should see the following:

"Virtual-Setup"

Verify Access

Lastly, with your Virtual Repository keyed as npm-default and assuming that you have a valid Artifactory username / password, configure your .npmrc accordingly:

.npmrc
registry=<artifactory_url>/artifactory/api/npm/<virtual_repository_key>/
<artifactory_url>/artifactory/api/npm/<virtual_repository_key>/:_password=<base64_artifactory_password>
<artifactory_url>/artifactory/api/npm/<virtual_repository_key>/:username=<artifactory_email>
<artifactory_url>/artifactory/api/npm/<virtual_repository_key>/:email=<artifactory_email>
<artifactory_url>/artifactory/api/npm/<virtual_repository_key>/:always-auth=true

The above will replace the following if your .npmrc file already contains the following (i.e. you are already using our product and are integrating Artifactory after the fact):

.npmrc
@neverendingsupport:registry=https://registry.nes.herodevs.com/npm/pkg/
//registry.nes.herodevs.com/npm/pkg/:_authToken=<NES_ACCESS_TOKEN>

Once the above steps are completed Artifactory will:

  • Attempt to download packages under the @neverendingsupport namespace from our private registry.
  • Fall through to the public npmjs.org registry if the package is not found in our private registry.

The Final Check

  1. Open a project containing both @neverendingsupport and a public package in its package.json.
  2. Execute an npm install command.

You should see successful output from the npm install command and the downloaded packages should appear in the node_modules directory.