Npm Private Clothing Installation Tutorial-Getting Started with Verdacio

  nginx, npm, verdaccio

0x00 preface

Recently, I wanted to build an npm private suit. I searched the information on the Internet and found two items:

Sinopia seemed to be very popular before, but the author abandoned the pit and found from an issue (see the end of the article) in the project that someone had fork over a project, namely verdaccio to be used in this article, which is currently under active maintenance.
Cnpm looks like there has been a commit recently, but it has not been release for a year and the installation is more complicated.

Finally, verdaccio was chosen.

Verdaccio is a lightweight private npm proxy registry built in Node.js

0x01 installation

Global installation

$ sudo npm install -g verdaccio

The author installed isverdaccio@3.2.0, neednode > 6.12.0,npm >=3.x

We use pm2 to manage the process and need to install pm2 globally.

Yarn can be used if npm installation fails

$ sudo npm install -g pm2

Start verdaccio

$ sudo pm2 start verdaccio

You can then see how the process started.

$ pm2 ls

Configure nginx Reverse Agent

Since verdaccio is started on port 4873 by default, nginx reverse proxy is configured to this port for convenience.
If you need to view the port number of verdaccio, you can use thepm2 lsView verdaccio’s pid and use:

$ netstat -nap | grep <pid>

View the port number used

The nginx configuration is posted below. centos nginx configuration file is available at/etc/nginx/conf.d/
Create a new profile and use the following

server {
  listen 80;
  server_name registry.npm.your.server;
  location / {
    proxy_pass    ;
    proxy_set_header        Host $host;

Restart nginx

$ sudo nginx -s reload

Use 0x02

Configuration in project

Visit:http://registry.npm.your.serverYou can see that verdaccio has been installed.

Then you can publish your npm package ~

For convenience, you can create a new one under the project directory..npmrcFile, write the following:


Then the package installed by the project will be downloaded from your own npm, and if it cannot be found, the official npm source will be found.

Modify upstream npm source

Since verdaccio uses npm’s official source by default, you can change it to Taobao’s source.

His profile is in/home/<username>/.config/verdaccio/config.yaml

There is a uplinks field


Change the url to do it

Reference article