Publishing Packages

To publish our package to our private registry, we will use a sample package as an example with the following file structure.

The file structure of the package.

  • The above is the file structure of our package, that will push it to our server, To do so we will run :
npm login --registry=http://localhost:4873/ 
npm publish --registry=http://localhost:4873/

The output of the command.

  • After publishing the package to the local server, The same will be reflected on the website.

The changes are reflected onto the website also.

Note: As we can see that, we just published our own packages to our private npm registry. And this is how we can utilize Verdaccio for creating our own NPM registry.

How to Set Up a Private NPM Registry

In this article we will learn how to install and configure a private NPM registry, and control authentication and access controls to users, also we will learn how to publish packages to npm and download and use them in our project. In this article, we will use Verdaccio, a lightweight and easy-to-use software. We will also learn how to create user accounts, and securely push and download packages from our server.

Table of Content

  • What is NPM Registry?
  • Choosing a Registry Solution
  • Installation Steps
  • User Access Control
  • Publishing Packages
  • Securing Your Registry
  • Conclusion

Similar Reads

What is NPM Registry?

An NPM registry is a centralized repository for storing and distributing JavaScript packages, accessible to developers for dependency management in their projects. There are two main types of NPM registries...

Choosing a Registry Solution

Verdaccio is one of the best solution for hosting private NPM registry due to several reasons...

Installation Steps

Step 1: First install the Verdaccio a local private npm registry. We will install Verdaccio globally on the system using the -g flag indicating that the package should be installed globally. We are installing it globally to increase ease of use when working on different projects....

User Access Control

To add a user to this registry, we will run the following command. This will provide a prompt asking for your username, password, email address. Next we will login into the admin panel through the login page....

Publishing Packages

To publish our package to our private registry, we will use a sample package as an example with the following file structure....

Securing Your Registry

No want their private repository / registry full of their code to get breached, so Verdaccio also offers many ways to secure our NPM registry, many of them are listed below :...

Conclusion

In this article we saw how to set up a private NPM registry using Verdaccio which can help us manage proprietary software packages safely. A private registry can sometimes offer more flexibility when dealing with private data like API keys, Tokens and environment variables. And we can easily download them, the only change will be to change the registry with the –registry flag to download a package from the registry. Verdaccio also caches all dependencies on demand and seep up installation in local and private network, We can also use a variety of plugins to customize our needs....

Contact Us