Setting up an NPM registry with JFrog Artifactory

See how to use Artifactory if you’re developing in node.js or JavaScript in general. Deploy your npm packages into local repositories, and proxy remote npm repositories such as Aggregate it all under a virtual repository and access all your npm packages via a single URL through Artifactory. Watch the screencast and learn how.

For more details on setting up your Npm registry, please refer to the JFrog Artifactory user guide. You can get started with a free 30-day trial here.

Artifactory Free Trial


Screencast Transcript

Hello and welcome. In this screencast we’ll talk about Artifactory, Npm integration, and we will see some benefits of Artifactory for JavaScript developers in general and Node.JS users in particular.

Using Artifactory as Your NPM Registry

By having Artifactory as your repository manager, you’ll be able to: publish your packages into local repository in Artifactory, install published packages through Artifactory local repositories and other packages of dependencies from remote repositories that proxy other sites, such as the NPM official registry, and aggregate multiple remote and local repositories under a single virtual repository, so resolution from multiple sites can be done against one single URL.

Creating Local, Remote and Virtual Npm Repositories

Let’s start by creating a remote repository in Artifactory that proxies the NPM registry. We’ll name the repository as npmjs-remote. Next enable the Npm support check box. We’ll use this repository later to install a package through Artifactory to proxy the Npm registry.

After we created the remote repository, we’ll create a local repository as well which we’ll service later to host our own private Npm packages.

Last, but not least, we’ll define the virtual repository with aggregates the npm-local and the npmjs-remote repositories we’ve created.

Configuring the Npm Client

Once we’re done with creating the repositories, the next step will be to config the .npmrc file to use our virtual repository to search and download packages and dependencies.

Installing, Downloading Dependencies and Publishing Through Artifactory

Now, let’s install some packages and see how it works.

As you can see, the queries are sent to Artifactory which return the package and its transitive dependencies.

Let’s see how it looks in Artifactory. As you can see, all the packages were cached in the remote repository cache. Let’s examine the express package by going to NPM info tab. Here we can see some details about the package, such as dependencies, licenses, etc. Let’s look at the logs in Artifactory.

This is the Artifactory log which contains the actual downloads from the Npm registry into the cache.

Now let’s create our own package and publish it into the Artifactory local repository. We will add the LRU package and use it with our project. Let’s also create index.js with the usage example that LRU provides.

Once the package is created, let’s publish it. For our example, we’ll use the default admin user.

Artifactory has a REST API query that returns an encoded authentication string. All we need to do is to add the query output to .npmrc file. It’s a good practice to also add an email address.

Now, we will add the publish config reference that points to the NPM local repository to our package.json file and start publishing.

As you can see, our NPM package is published into our local repository in Artifactory.

Let’s see it in Artifactory.

NPM info tab we can see the LRU dependency we added. Naturally, the metadata files were created as well.

This concludes our NPM screencast. Of course, that is just a nutshell and there are plenty of other useful features that Artifactory provides. For more information please visit our website and user guide. Thank you for watching and stay tuned for more screencasts from JFrog.