How to manage internal/external package with Artifactory

How to implement Artifactory NPM registry for internal and external package management

Introduction

Many large-scale development teams use a local package manager like Artifactory to storage local versions of both internal and external development packages (e.g. NPM, Maven, Docker etc.).

The benefits of having a local package manager are many. Therefore, I have written this short guide for how to navigate and use the package manager of Artifactory.

This guide is based on the example of a NPM package, but should be somewhat translatable to any package-type.

INTEGU - Artifactory - Jfrog

Internal and External NPM packages

Artifactory NPM registry can be used for two reasons:

  • NPM-remote: Using the Artifactory NPM registry will ensure that any NPM dependency will be stored within a storage managed and maintained only by this department.
    Therefore, it does not matter if the source of the NPM is removed. There is no external dependency.
  • NPM-local: We are able to create our own NPM package and share them internally.

Both “NPM-remote” and “NPM-local” are accessed through the “NPM” registry.

It is therefore only necessary to point to the NPM registry from your local developer environment.

It is a prerequisite for the following guide that an internal NPM package has been added to Artifactory. For the sake of the guide, we will reference this NPM package by the name of “new-npm”.

How to access Artifactory NPM registry from local environment

Step 1: Modify the “.npmrc” configuration file.

Open the .npmrc-file (usually located in “C:\Users\\.npmrc” on Windows) with a text editor.

If the file does not already exist, just create it.

Add the following configurations. Save and close afterwards.

				
					registry=https://<artifactory_url>/artifactory/api/npm/npm/
				
			

That’s all.

If you SSL certification is not correctly setup, if might be worth testing the connection with strict-“ssl=false” in the file as well.

Registry has now been change from the public NPM to the Artifactory NPM registry.

Step 2: (Optional): Test a local NPM package

Go to any NPM project and add a dependency to a NPM package only available through the NPM-local registry. (e.g. “new-npm”)

Perform a NPM install to see dependency is being correctly downloaded and included in the project.

If the download is successful, the NPM registry is successful.

Add dependency to the package.json file.

				
					...
“dependencies”: {
   “new-npm”: “^1.0.0”
   ...
}

				
			

Command line:

				
					npm install
				
			

Recommended Reading

No references for this article…

About

Hi, I'm the Author

My name is Daniel H. Jacobsen and I’m a dedicated and highly motivated software developer with a masters engineering degree within the field of ICT. 

I have through many years of constantly learning and adapting to new challenges, gained a well-rounded understanding of what it takes to stay up to date with new technologies, tools and utilities. 

The purpose of this blog is to share both my learnings and knowledge with other likeminded developers as well as illustrating how these topics can be taught in a different and alternative manner.

If you like the idea of that, I would encourage you to sign up for the newsletter.

Cheers! 🍺

Didn't Find What You Were Looking For?

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Scroll to Top
INTEGU - Cookie-consent

INTEGU uses cookies to personalize your experience and provide traceability for affiliate links. By using the website, you agree to these terms and conditions. To learn more see the privacy policy page.