In case the
npm registry goes down, it’s wise to have a backup registry.
ssh into your server.
npm i -g verdaccio. a free private npm registry
edit the main configuration file, located at
for security reasons, replace all occurrences of
in vim you would run something like this:
gc for “global” and “confirm” replacement, so that you double check if you really want to replace the occurrence.
authentication with htpasswd
set up a
~/htpasswd file with the allowed users. you can create a config using this secure htpasswd generator (it’s the recommended one).
add the resulting line to the
verdaccio to use that file, using the
auth: htpasswd: file: $REPLACE_WITH_YOUR_HOME_PATH/htpasswd # Maximum amount of users allowed to register, defaults to "+inf". # You can set this to -1 to disable registration. max_users: -1
using the htpasswd file you have enabled registry access using the npm cli and http access to the web dashboard.
for the web dashboard to be available on the web, you need to configure the
listen: - npm.YOUR_COMPANY.com:4873
http if you feel so inclined. local network addresses if you’re behind a proxy.
npm client setup
you could manually add a line to the
.npmrc file, but I used:
npm adduser --registry https://npm.YOUR_COMPANY.com:4873
authenticate to it and you should be good to go.
this will set the npm registry in your
.npmrc to “https://npm.YOUR_COMPANY.com” and add a line to authenticate to it:
keep it running
pm2, but you have more options like
pm2 start --name VERDACCIO verdaccio pm2 save pm2 startup
reverse proxy with haproxy
if haproxy terminates your SSL requests, you can put verdaccio behind that.
snippet from the haproxy.cfg, your backend for npm could look like this:
backend npm option forwardfor http-request set-header X-Forwarded-Proto https server npm1 npm.YOUR_COMPANY:4873 check
logo from https://verdaccio.org/docs/en/logo