Build NPM private library on the server



I have installed Linux CentOS 8.3 and used verdaccio to build a warehouse. The process is recorded in this article, which may provide a reference.


  • Installing node on Linux server
  • Installing verdaccio through NPM
  • Start verdaccio
  • Configure login user
  • Publish / install

Linux server installation node

  • Install the Linux version of node through the command:

    tar xvf node-v14.16.1-linux-x64.tar.xz
  • Create soft links to make node and NPM globally effective and easy to operate

    //In the directory where the node compressed package is extracted:
    ln -s node-v14.16.1-linux-x64/bin/node /usr/local/bin/
    ln -s node-v14.16.1-linux-x64/bin/npm /usr/local/bin/
  • Check whether the installation is successful:

    npm -v
    node -v
    //The output version number completes the installation


  • Using NPM installation, you can also create a soft link for verdaccio

    npm i verdaccio -g
    //In the directory where the node compressed package is extracted:
    ln -s node-v14.16.1-linux-x64/bin/verdaccio /usr/local/bin/
    verdaccio -v
    //The output version number completes the installation

Start the verdaccio service

  • Direct input commandverdaccioYou can start it, but the external network is not allowed in the default configuration of verdaccio. You can add a line in the configuration file config.yaml of verdaccio:listen:, or add parameters at startup--listenor-l, configure the address and port number:

    verdaccio -l
    //Start successful

Then, access the server’s public network IP + port number 4873. If you can’t access it, consider whether the firewall and server security group rules open the port.

After successful access, you can enter the verdaccio home page. At this time, you can view the items and modules in the warehouse.

Client configuration, publishing and installation

  • Sign in

    NPM addUser -- registry http: // server address: 4873/
    //Enter user name, password and email address
  • release

    //Under the module path to be published:
    NPM publish -- registry http: // server address: 4873/
    //Note that change the private in package.json to false, indicating a non private module
    //The version in package.json needs to be updated for each release, indicating the updated version number
  • install

    NPM install module name -- registry http: // server address: 4873/

Each of the above operations is for the source operation separately. You can also change the source to the address of the private library by default through global configuration

  • View the current mirror source address:npm get registry
  • Set the source address of the server private library:NPM set registry http: // server address: 4873

    Then, the next operations point to the source by default

Similarly, it can be found at the beginning of the projectpackage.jsonAdd a configuration and point to the address you want to publish:

"publishConfig": {
    "Registry": "http: // server address: 4873"

reference resources:Verdaccio is installed on a Linux server