Use verdaccio to build NPM privatization warehouse from 0 to 1 on Linux server


There is a server from the back end. There is nothing on it. I want to build an NPM privatization warehouse to put some public components of the company’s projects and the SDK of the project. I want to make the library into a library and introduce it into the project for use. Let’s do it.

Log in to the server first,

Build environment

The first step is to install nodejs

yum install -y epel-release
yum install -y nodejs

node -vCheck it out

Use verdaccio to build NPM privatization warehouse from 0 to 1 on Linux server

Good guy, the version is so low! just6.17.1
Upgrade the version and install itnodejsPackage management tools

npm install -g n

Some common commands:

N stable // update the node of the current system to the latest "stable version"
N LTS // long term support
N latest // latest version
N 10.14.2 // specify the installation version
N // view the installed version
N RM 10.14.2 // delete the specified version

Command line inputnenter
Use verdaccio to build NPM privatization warehouse from 0 to 1 on Linux server

Select a version and press enter again
node -vCheck again, the version is still displayedv6.17.1The version hasn’t changed after switching!

Baidu found that the current version is not the latest version, and then the latest version has been installed. The reasons why it does not take effect are as follows:
The default installation directory of node is inconsistent with the directory installed by using the management tool n,

View the current node installation path

which node

The N default installation path is/usr/local, currentnodeInstallation path andnThe paths of are inconsistent and need to pass throughN_PREFIXVariable to modify n’s default node installation path.

To edit an environment profile:vim ~/.bash_profile

Modify node installation location: add at the endexport PATH=/usr/local/bin:$PATH shift+:wqSave exit

Use verdaccio to build NPM privatization warehouse from 0 to 1 on Linux server

Make the new configuration effective:source ~/.bash_profile

Reinstall stable version:n stable

To view the current node version:node -v(it is the latest stable version)

All right, let’s get down to business. Installverdaccio!


npm i -g verdaccio

Command line inputverdaccioEnter startverdaccio, you can see the profile address in the first line:

config file  - /root/.config/verdaccio/config.yaml

In the last line of the configuration file, addlisten:, if there is no such line by default, it can only be accessed locally. After addition, it can be accessed through the Internet.


  1. Install PM2
    npm install -g pm2
  2. Start verdaccio with PM2
    pm2 start verdaccio
  3. View the real-time log of the process verdaccio under PM2 daemon
    pm2 show verdaccio
  4. View the log command under this path in real time
    tail -f /home/admin/.pm2/logs/verdaccio-out-0.log

There are several commands commonly used in the configuration process

Netstat - tunlp // view all port processes
Netstat - tunlp|grep port number // view the specified port number
Kill port number // kill the process with the specified port number
Telnet IP address and port number. // telnet needs to be installed. Check whether the address and port are used
//For example
telnet localhost 4873
telnet 4873

At this time, the server is configured. For example, the address of the server is192.168.0.1, normally accessed in our browserhttp:// can access it (the port should be added and the firewall should be closed!)

Use verdaccio to build NPM privatization warehouse from 0 to 1 on Linux server

Manage source publishing packages

Next, we will release the package to our privatized warehouse!
Install a switch firstnpmSource toolsnrm

npm i nrm -g
NRM list or NRM LS // view the source list
NRM add [name] [source url] // add source
NRM use [name] // use source
NRM del [name] // delete source

usenrm useSwitch to the address of the privatized warehouse just created
Sign in:

NPM whoamI // view the currently logged in user
npm adduser --registry http://yourip:4873/


npm publish --registry http://yourip:4873/
//If you switch to the current source, you can directly NPM publish

Then refresh to see the package you released!

Update package:

1. Modify the version number of the package.json version field
2. Command line: NPM publish

reference resources:…
After upgrading node, there is still a problem with the original version
Installing Telnet for Linux…