Skip to content

Techeons

Imagine | Explore | Innovate

Menu
  • Home
Menu

How to setup a private NPM registry using Verdaccio

Posted on September 3, 2024

Verdaccio is a lightweight, open-source package manager built on Node.js. It allows you to:

  • Host your own packages: Store and manage your private packages, making it ideal for teams and organizations.
  • Cache public packages: Speed up package installation by caching public packages from registries like npm.
  • Create a proxy registry: Set up a proxy to access public packages while also hosting your private packages.

Verdaccio supports various package formats, including npm, yarn, and pnpm. Its simplicity, flexibility, and scalability make it a popular choice for managing packages in a local environment.

Key Features:

  • Private package hosting
  • Cache and proxy support
  • Multi-protocol support (npm, yarn, pnpm)
  • Web interface for easy package management
  • Plugin architecture for customization

Use cases:

  • Private package management for teams and organizations
  • Offline package installation
  • Local package caching for faster installation
  • Custom package registries for specific use cases

Setting up a private npm registry using Verdaccio

Prerequisites

  • Node.js (version 14 or higher)
  • npm (version 6 or higher)
  • Docker (optional)

Method 1: Global Installation

1) Install Verdaccio globally using npm:

npm install -g verdaccio

2) Start Verdaccio:

verdaccio

Method 2: Local Installation

1) Create a new directory for your Verdaccio instance:

mkdir verdaccio
cd verdaccio

2) Initialize a new npm project:

npm init -y

3) Install Verdaccio locally:

npm install verdaccio

4) Start Verdaccio

npx verdaccio

Method 3: Using Docker

1) Pull the official Verdaccio Docker Image:

docker pull verdaccio/verdaccio

2) Run the container:

docker run -d -p 4873:4873 verdaccio/verdaccio

Publish a package:

npm publish --registry http://<ip-address>:4873

To use it locally, set <ip-address> to localhost

Configure npm to use Verdaccio

Set Verdaccio as the registry for your npm client:

npm config set registry http://<ip-address>:4873

To use it locally, set <ip-address> to localhost

Alternatively, configure your specific project to use Verdaccio

Create a .npmrc file:

@xyz:registry=http://<ip-address>:4873

To use it locally, set <ip-address> to localhost

Install the packages:

npm install @xyz/shared-components-1
npm install @xyz/shared-components-2

Troubleshooting

    Check the Verdaccio logs for errors: verdaccio logs

    Verify that the storage directory has proper permissions.

Security Considerations

    Use a secure password and consider enabling SSL/TLS encryption.

    Limit access to your Verdaccio instance using a firewall or reverse proxy.

Share on Social Media
x facebook pinterest linkedin tumblr reddit emailwhatsapptelegrammastodon

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • Nginx: How to increase timeout for Nginx
  • Cheat Sheet: Essential Git Commands
  • Setting a default shell in Linux
  • Setting up Composer on Linux
  • Switch easily between Python versions on a Mac using pyenv

Tags

ai alerting aws b2 backblaze certificate cheatsheet cloud commands data-science datalake devops dns docker dremio git gitlab infra jenkins kubernetes linux metabase minikube minio monitoring mount mysql nginx nodejs notebooks openssh php python scala secrets spark ssh ssl ubuntu ufw usb web dev tools windows xampp zeppelin

©2026 Techeons | Design: Newspaperly WordPress Theme