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.

Setup Instructions

Create a Remote Repository

  1. Navigate to the Administration tab (top navbar next to Application)
    JFrog Artifactory interface showing the Administration tab selected in the top navigation bar
  2. Select Repositories (left side navbar)
    JFrog Artifactory Administration page showing the Repositories option in the left sidebar navigation
  3. Navigate to the Remote subtab.
    JFrog Artifactory Repositories page showing the Remote subtab selected
  4. Select Create Repository > Remote, and then select NPM as the type.
    JFrog Artifactory showing the Create Repository dropdown menu with Remote option visibleJFrog Artifactory repository type selection screen showing NPM selected as the repository type
  5. Configure the following parameters on the Basic tab:
    JFrog Artifactory Basic tab configuration form for creating an NPM remote repository
    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
  6. Configure the following on the Advanced tab:
    JFrog Artifactory Advanced tab configuration form for the NPM remote repository showing Bypass HEAD Requests and Disable URL Normalization checkboxes
    • Ensure Bypass HEAD Requests is checked
    • Ensure Disable URL Normalization is checked

The final results should look similar to the following:

Basic

Completed JFrog Artifactory Basic tab configuration for NPM remote repository showing Repository Key, URL, Username, Password, Include Patterns, and Remote Mapping Layout fields filled in

Advanced

Completed JFrog Artifactory Advanced tab configuration for NPM remote repository showing Bypass HEAD Requests and Disable URL Normalization options checked

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. Completed JFrog Artifactory Basic tab configuration for npmjs.org remote repository showing Repository Key set to npm-remote and URL set to https://registry.npmjs.org

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
    JFrog Artifactory interface showing the Administration tab selected in the top navigation bar
  2. Select Repositories
    JFrog Artifactory Administration page showing the Repositories option in the left sidebar navigation
  3. Navigate to Virtual subtab
    JFrog Artifactory Repositories page showing the Virtual subtab selected
  4. Select Create Repository > Virtual
    JFrog Artifactory showing the Create Repository dropdown menu with Virtual option visible

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:

JFrog Artifactory Virtual Repository configuration showing Selected Repositories list with npm-remote at the top and nes at the bottom

Verify Access

Lastly, with your Virtual Repository keyed as npm-default and assuming that you have a valid Artifactory username / password, update your .npmrc file 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.