1. Install NVM (no, or already installed, please skip)

The curl - o - https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bashCopy the code
  1. Install Sinopia (or Verdaccio – newer)
 nvm install stable
 
 
 npm install -g sinopia
Copy the code

Start the sinopia

3. Manage Verdaccio through PM2 (older method, docker, etc.)

Start Verdaccio with pm2 start

pm2 start verdaccio
pm2 stop verdaccio
Copy the code

  1. Install nginx
Wget HTTP: / / http://nginx.org/download/nginx-1.18.0.tar.gzCopy the code
  1. Configure nginx
server { listen 80; server_name npm.bjnja.com; Location / {proxy_pass http://127.0.0.1:4873; }}Copy the code

Nginx installation on Ali Cloud has some trouble, apt-get version is low, GCC, etc., can’t install yum, need to upgrade, in fact, the Ubuntu version of Ali cloud is too old, a lot of things do not support, need to upgrade

sudo apt-get update
Copy the code
  1. Customer usage is managed using NRM
npm install -g nrm
Copy the code

Use NRM add to add our private library

nrm add nja http://npm.bjnja.com
Copy the code
nrm ls npm ---- https://registry.npmjs.org/ cnpm --- http://r.cnpmjs.org/ taobao - https://registry.npm.taobao.org/ nj ----- https://registry.nodejitsu.com/ rednpm - http://registry.mirror.cqupt.edu.cn/ npmMirror https://skimdb.npmjs.com/registry/ * nja edunpm - http://registry.enpmjs.org/ - http://npm.bjnja.com/ USES NRM use Nja free switching; Then you can use itCopy the code

Added: Sinopia authors are no longer maintained. Verdaccio, a sinopia branch, is recommended

Github.com/verdaccio/v…

In fact, the following domain name can not be configured first, first install verdaccio, you can use the localhttp://127.0.0.1:4873 test, no problem, and then engage in company domain name correspondence

If we want to publish packages on the local Verdaccio service, we need to ensure that our Verdaccio service is running and check the registry currently in use

NRM ls // Use NRM use to switch to the NRM use of its own serviceCopy the code

Then we need to create a new user name in the local service

NPM adduser --registry http://localhost:4873 // Obtain ca information if HTTPS is used NPM set CA null // publish locally NPM publish --registry http://localhost:4873 npm i -g <moduleName>Copy the code

Refer to the address

Use Docker + Verdaccio to build NPM private library

Build NPM with Sinopia