NPM registry setup in JFrog Artifactory
Hello. Thank you for choosing JFrog. In this video, we’ll be covering how to set up NPM repositories in Artifactory and we will see how to publish NPM reports, NPM packages to Artifactory, as well as how NPM packages can be installed through Artifactory.
To get started with this you’ll need the latest version of Artifactory installed as well as the latest version of NPM installed. Let’s go ahead and get started.
Here we are in the Artifactory homepage, logged in as an admin user to get started setting up NPM, simply go to the admin menu at the top right-hand corner and click quick setup. As you can see, NPM is one of several package managers for which Artifactory can create default repositories for.
Let’s go ahead and select it. As you can see, three repositories have been created in Artifactory. The first is NPM local, to which we will be publishing our packages. The second is NPM remote. The services is a proxy for an NPM upstream repository, for which we can download dependencies for our projects and install just general NPM packages. By default, this repository points to registry.NPMjs.org which is the public registry used by NPM.
The final repository is the NPM virtual repository. This repository aggregates the content of both local and remote repositories into a single repository, so that you can use a single end point for all your NPM users.
Now that we’ve set up our repositories, let’s go ahead and set up our NPM client. Head over to the Artifactory artifacts browser and select the virtual repository, which is the single end point we will be using for all our NPM repositories. Go ahead and click the set me up button and enter in your password. You now how everything you need to set up your anything NPM client to work with Artifactory.
The first thing you’ll need to do is set our Artifactory repository as our NPM client’s registry. Simply copy this command to clipboard and our registry is now set.
The next thing we need to do is set our authentication. There’s two ways to authenticate. The first would be to simply use the NPM login each time, but we won’t be doing that. For this tutorial, we will be using basic authentication, simply copy the authentication information here and add it to your NPMrc file. Okay, as you can see, the registry is already set up. We’ll go ahead and cut and paste our authentication information, right afterwards.
We are now fully set up to publish packages in Artifactory and install packages through Artifactory. Let’s go ahead and create a simple NPM project to see how this is done. Before we go ahead and create this project I want to point out here, you can see that all our NPM repositories are empty because we haven’t downloaded or installed anything yet. Let’s go ahead and initiate a simple project, and let’s go ahead and install a simple package into this project. We’ll install the bugs since it’s quite small.
Now let’s go ahead and publish our packages to NPM or to our Artifactory repository.vGo ahead and take a look at our repositories again. Once we look in our remote repository now we can see that debug and its dependency have both been downloaded in our repository. If we look into our local repository, we can see that we have published for example, project to Artifactory. And if you look into our virtual repository, we can see that that debug, its dependency and our project have all been gathered into a single repository here.
I hope this tutorial was helpful in teaching you about how to set up Artifactory with NPM. And I hope you enjoy the rest of your experience with the Jfrog platform. Thank you for joining me today.