I’ve just successfully set up Verdaccio on my laptop. I’m writing down the steps so that I can repeat the process on my desktop and on my future machines. Also, it seems to be independant of the actual Node version I use.

Verdaccio is a lightweight personal npm registry copy. Meaning, any time I install something with npm, I will actually look locally to my instance of the registry first. If the thing is there: zap! Fast speed. If I haven’t installed it yet , Verdaccio will fetch the Nodejs package from npmjs.com registry and keep a local copy anyway. All this is mostly useful when testing publishing local packages, and when the actual npmjs registry is unreachable (e.g. their or mine Internets are down.)

So, steps:

1. Install nvm and node

Install nvm and with it, [Node].

2. Install verdaccio globally

npm i -g verdaccio

3. Run it the first time manually.

This creates a config file, $HOME/.config/verdaccio/config.yaml. Adjust if you need to.


So far, these have been standard Nodejs things. Now ono Linux stuff.

4. Create a local start script

Create a local bash script that will source nvm - to get the currently used default version of Node, and then to start Verdaccio. Mine is called verdacio.sh and lives in $HOME/.local/bin:

#!/bin/bash
export NVM_DIR="/home/zlatko/.nvm" 
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
verdaccio  --config /home/zlatko/.config/verdaccio/config.yaml

Also note where this takes the config file from if you’ve changed it.

5. Create a user systemd service

I create the user service and not a global one, as with this I avoid a whole nbunch of permissions, ownership etc issues that I’d have if I wanted to run verdaccio as a separate system user (which would then need their own instance of nvm management etc etc).

The systemd service I have is created in $HOME/.config/systemd/user/verdaccio.service:

[Unit]
Description=Verdaccio lightweight npm proxy registry

[Service]
Type=simple
Restart=on-failure
ExecStart=/home/zlatko/.local/bin/verdaccio.sh
[Install]
WantedBy=default.target

A point that is different from the Verdaccio docs is that I had to remove the User key - if you run a systemd service with the --user flag, then the User and Group specifiers get in the way.

6. Now add it up.

“Read” the service, enable it, run it:

systemctl --user daemon-reload
systemctl --user enable verdaccio
systemctl --user start verdaccio

Now your verdaccio should be running! If there are any issues, you can track what systemd is doing with:

journalctl --user -f -u verdaccio.service

A point to note is that none of this requires root normally, and I think I was only asked to authenticate once, when I was enabling the service.