### Install Node Version Manager (NVM) and Node.js Source: https://verdaccio.org/docs/amazon Installs NVM to manage Node.js versions, then installs the latest stable Node.js. This is a prerequisite for installing Verdaccio. ```bash sudo apt update wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash exit nvm install node ``` -------------------------------- ### Start Verdaccio Server Source: https://verdaccio.org/docs/next/what-is-verdaccio This command starts the Verdaccio server. Ensure Verdaccio is installed globally or locally in your project to use this command. ```bash $> verdaccio ``` -------------------------------- ### Run Verdaccio Server Source: https://verdaccio.org/docs/next/installation Starts the Verdaccio local registry server. It logs storage path, htpasswd file location, HTTP address, and version. This is a basic command to get the server running. ```bash $> verdaccio info -=- local storage path /Users/user/.local/share/verdaccio/storage/.verdaccio-db.json info --- using htpasswd file: /Users/user/.config/verdaccio/htpasswd info --- http address http://localhost:4873/ info --- version: 6.0.0-6-next.48 info --- server started ``` -------------------------------- ### Start Verdaccio Registry and Publish Package (Bash) Source: https://verdaccio.org/docs/e2e This Bash script demonstrates how to start a local Verdaccio registry, configure it, log in, and publish an npm package. It's a simplified example extracted from create-react-app for E2E testing. It requires `verdaccio` and `npm-auth-to-token` to be installed. ```bash #!/bin/sh set -e local_registry="http://0.0.0.0:4873" # start local registry tmp_registry_log=$(mktemp) sh -c "mkdir -p $HOME/.config/verdaccio" sh -c "cp --verbose /config.yaml $HOME/.config/verdaccio/config.yaml" sh -c "nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &>$tmp_registry_log &" # wait for `verdaccio` to boot grep -q 'http address' <(tail -f $tmp_registry_log) # login so we can publish packages sh -c "npm-auth-to-token -u test -p test -e test@test.com -r $local_registry" # Run nmp command sh -c "npm --registry $local_registry publish" ``` -------------------------------- ### Run Verdaccio as a Background Service with PM2 Source: https://verdaccio.org/docs/amazon Starts Verdaccio as a background service using PM2, ensures it launches on system startup, and saves the current process list. This command sequence ensures Verdaccio runs reliably. ```bash pm2 start verdaccio pm2 stop verdaccio pm2 delete verdaccio pm2 startup which verdaccio pm2 start /home/ubuntu/.nvm/versions/node/v17.1.0/bin/verdaccio pm2 status pm2 save ``` -------------------------------- ### Install and Start Verdaccio Service with WinSW (Windows) Source: https://verdaccio.org/docs/windows Installs and starts the Verdaccio Windows service after configuring it with WinSW. This involves navigating to the Verdaccio directory and executing WinSW commands. ```bash cd c:\verdaccio verdaccio-winsw.exe install verdaccio-winsw.exe start ``` -------------------------------- ### Register User and Login to Verdaccio Registry Source: https://verdaccio.org/docs/amazon Registers a new user for the Verdaccio registry and logs in using the created credentials. This allows authenticated access for publishing and retrieving packages. ```bash npm adduser npm set registry http://your-ec2-public-ip-address:4873 npm login ``` -------------------------------- ### Install Verdaccio and PM2 for Background Service Source: https://verdaccio.org/docs/amazon Installs Verdaccio, the private npm registry, and PM2, a process manager for Node.js applications, to run Verdaccio in the background. ```bash npm i -g verdaccio pm2 ``` -------------------------------- ### Publish Package to Verdaccio Registry Source: https://verdaccio.org/docs/amazon Publishes a custom library package (e.g., a .tgz file) to the configured Verdaccio private registry. This makes the package available for installation by other users or projects. ```bash cd [custom library package path] npm publish your-library-name-0.0.1.tgz or npm publish or npm publish --registry http://your-ec2-public-ip-address:4873 ``` -------------------------------- ### Verdaccio start.js for versions < v3.0 Source: https://verdaccio.org/docs/iss-server An alternative start script for older Verdaccio versions (< v3.0) that configures the listening port using an environment variable. It directly requires the Verdaccio CLI. ```javascript process.argv.push('-l', 'unix:' + process.env.PORT); require('./node_modules/verdaccio/src/lib/cli.js'); ``` -------------------------------- ### Configure Verdaccio Service with WinSW (Windows) Source: https://verdaccio.org/docs/next/windows This snippet demonstrates how to set up Verdaccio as a Windows service using the WinSW tool. It involves placing the WinSW executable, creating a configuration XML file, and then installing and starting the service via the command line. This approach ensures Verdaccio runs continuously and restarts if it crashes. ```xml verdaccio Verdaccio Verdaccio private npm proxy. node c:\verdaccio\node_modules\verdaccio\src\lib\cli.js -c c:\verdaccio\config.yaml c:\verdaccio\ ``` ```shell cd c:\verdaccio verdaccio-winsw.exe install verdaccio-winsw.exe start ``` -------------------------------- ### Run Verdaccio Server Source: https://verdaccio.org/docs/installation Starts the Verdaccio server using the CLI command. This command will automatically locate or create a default configuration file and start the HTTP server, typically on port 4873. ```shell $> verdaccio warn --- config file - /home/.config/verdaccio/config.yaml warn --- http address - http://localhost:4873/ - verdaccio/5.0.0 ``` -------------------------------- ### Create Verdaccio Directory and Install Locally (Windows) Source: https://verdaccio.org/docs/next/windows This snippet shows how to create a directory for Verdaccio and install it locally using npm. It's recommended to install locally to avoid potential npm issues with global installations. ```shell mkdir c:\verdaccio cd c:\verdaccio npm install verdaccio ``` -------------------------------- ### Create Verdaccio Directory (Bash) Source: https://verdaccio.org/docs/windows Creates a directory for Verdaccio installation and navigates into it. This is a prerequisite for installing Verdaccio. ```bash mkdir `c:\verdaccio` cd `c:\verdaccio` ``` -------------------------------- ### Example Verdaccio Authentication Configuration Source: https://verdaccio.org/docs/plugin-auth This is an example configuration snippet for Verdaccio, specifically showing how to configure an authentication plugin. It uses the `htpasswd` plugin as an example, where `htpasswd` is the suffix of the plugin name (e.g., `verdaccio-htpasswd`). The rest of the configuration would be specific parameters for the chosen plugin. ```yaml auth: htpasswd: file: ./htpasswd ``` -------------------------------- ### Install Node.js and Verdaccio Source: https://verdaccio.org/docs/next/amazon This snippet shows the commands to update apt, install Node Version Manager (nvm), install Node.js, and globally install Verdaccio and PM2 for background service management. Ensure nvm is installed and closed/re-opened before installing Node.js. ```bash sudo apt update wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash exit nvm install node npm i -g verdaccio pm2 ``` -------------------------------- ### Install Verdaccio Theme Plugin (Shell) Source: https://verdaccio.org/docs/next/plugin-theme Command to install a custom Verdaccio theme plugin globally using npm. The plugin name must start with `verdaccio-theme-` to be recognized by Verdaccio. ```shell $> npm install --global verdaccio-theme-dark ``` -------------------------------- ### Run Verdaccio Docker Container Source: https://verdaccio.org/docs/installation Starts a Verdaccio Docker container, mapping the container's port 4873 to the host's port 4873. This provides a quick way to run Verdaccio without a global installation. ```docker docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio ``` -------------------------------- ### Start Verdaccio CLI with Configuration Source: https://verdaccio.org/docs/cli This command starts the Verdaccio application, specifying the port to listen on and the location of the configuration file. It's a fundamental command for running Verdaccio. ```shell verdaccio --listen 4000 --config ~./config.yaml ``` -------------------------------- ### Start Verdaccio Registry and Publish Package (Bash) Source: https://verdaccio.org/docs/next/e2e This Bash script demonstrates how to start a local Verdaccio registry, configure it, and then publish an npm package to it. It includes steps for logging in to the registry and executing the publish command. Dependencies include `verdaccio`, `npm`, and `npm-auth-to-token`. ```bash #!/bin/sh set -e local_registry="http://0.0.0.0:4873" # start local registry tmp_registry_log=`mktemp` sh -c "mkdir -p $HOME/.config/verdaccio" sh -c "cp --verbose /config.yaml $HOME/.config/verdaccio/config.yaml" sh -c "nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &>$tmp_registry_log &" # wait for `verdaccio` to boot grep -q 'http address' <(tail -f $tmp_registry_log) # login so we can publish packages sh -c "npm-auth-to-token -u test -p test -e test@test.com -r $local_registry" # Run nmp command sh -c "npm --registry $local_registry publish" ``` -------------------------------- ### Install Verdaccio using npm Source: https://verdaccio.org/docs/iss-server These commands download and install Verdaccio and its dependencies within the specified project folder. Ensure you are in the correct directory before execution. ```bash cd c:\verdaccio npm install ``` -------------------------------- ### Install and Use 'forever' for Process Management (Node.js) Source: https://verdaccio.org/docs/server-configuration Instructions to install the 'forever' Node.js package globally and use it to start the Verdaccio process. 'forever' keeps the Verdaccio server running continuously, automatically restarting it if it crashes. ```bash $ sudo npm install -g forever $ forever start `which verdaccio` ``` -------------------------------- ### Start Verdaccio Server using runServer API (Node.js) Source: https://verdaccio.org/docs/verdaccio-programmatically This code shows how to use the `runServer` function from the Verdaccio module to start the server. It supports starting with default configuration, a specified config file path, or a configuration object. The server can then be started on a specific port. This is the recommended method for future compatibility. ```javascript const { runServer } = require('verdaccio'); // Start with default configuration const app = await runServer(); // Start with a specific config file const app = await runServer('./config/config.yaml'); // Start with a configuration object const app = await runServer({ configuration }); app.listen(4000, (event) => { // do something }); ``` -------------------------------- ### Run Verdaccio Docker Image Source: https://verdaccio.org/docs/next/installation Starts the Verdaccio service using its official Docker image. This command maps port 4873 from the host to the container and names the container 'verdaccio'. ```bash docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio:nightly-master ``` -------------------------------- ### Start Verdaccio Programmatically with Node.js Source: https://verdaccio.org/docs/next/node-api This snippet demonstrates how to start a Verdaccio server programmatically using its Node.js API. It requires the 'verdaccio' package and defines a configuration object for storage, authentication, uplinks, and package access. The server is then started on a specified port. ```javascript const startServer = require("verdaccio").default; let config = { storage: "./storage", auth: { htpasswd: { file: "./htpasswd" } }, uplinks: { npmjs: { url: "https://registry.npmjs.org/", } }, self_path: "./", packages: { "@*/*": { access: "$all", publish: "$authenticated", proxy: "npmjs", }, "**": { proxy: "npmjs" } }, log: { type: "stdout", format: "pretty", level: "http", }; startServer( config, 6000, undefined, "1.0.0", "verdaccio", (webServer, addrs) => { webServer.listen( addrs.port || addrs.path, addrs.host, () => { console.log(`verdaccio running on : ${addrs.host}:${addrs.port}`); } ); } ); ``` -------------------------------- ### Verdaccio start.js for versions >= v3.0 Source: https://verdaccio.org/docs/iss-server This script configures command-line arguments for Verdaccio, setting the listening port via an environment variable and specifying the configuration file. It then initiates the Verdaccio CLI. ```javascript process.argv.push('-l', 'unix:' + process.env.PORT, '-c', './config.yaml'); require('./node_modules/verdaccio/build/lib/cli.js'); ``` -------------------------------- ### Install Next Major Release of Verdaccio Source: https://verdaccio.org/docs/installation Installs the pre-release version of Verdaccio 7.x, useful for testing or contributing to the next major release. It's recommended not to use alpha versions in production environments. ```shell npm install -g verdaccio@7-next ``` -------------------------------- ### Install Verdaccio Locally (npm) Source: https://verdaccio.org/docs/windows Installs Verdaccio locally within the project directory to avoid potential npm global installation issues. Requires Node.js and npm to be installed. ```bash npm install verdaccio ``` -------------------------------- ### Install Package from Verdaccio Registry Source: https://verdaccio.org/docs/installation Installs a package using npm, explicitly specifying the Verdaccio registry URL. This is useful for testing installations from your private registry or when you don't want to change the global default. ```shell npm install --registry http://localhost:4873 ``` -------------------------------- ### Configure Verdaccio Listening and Access Source: https://verdaccio.org/docs/amazon Modifies the Verdaccio configuration file (`config.yaml`) to listen on all network interfaces and restricts access to authenticated users only. This ensures secure access to the private registry. ```yaml listen: - 0.0.0.0:4873 Replace "access: $all" with "access: $authenticated" (Optional) Replace "#max_users: 1000" with "max_users: 1" ``` -------------------------------- ### Install Verdaccio Active Directory Plugin Source: https://verdaccio.org/docs/next/plugins Installs the `verdaccio-activedirectory` plugin globally using npm. This plugin is used for authentication against an Active Directory server. ```bash $> npm install --global verdaccio-activedirectory ``` -------------------------------- ### Configure Verdaccio Service with WinSW (Windows) Source: https://verdaccio.org/docs/windows Sets up Verdaccio as a Windows service using WinSW. Requires downloading WinSW, renaming it, and creating an XML configuration file. Assumes Verdaccio is installed in `c:\verdaccio`. ```xml verdaccio verdaccio Verdaccio is a lightweight private npm proxy registry. node c:\verdaccio\node_modules\verdaccio\src\lib\cli.js -c c:\verdaccio\config.yaml c:\verdaccio ``` -------------------------------- ### Install Attempt and Forbidden Error - Shell Source: https://verdaccio.org/docs/packages This example shows a command-line attempt to install a package ('npmuser-core') after configuring specific access rules. The output indicates a '403 Forbidden' error, confirming that the access control rules are effectively blocking the unauthorized user. ```bash $ npm install npmuser-core npm install npmuser-core npm ERR! code E403 npm ERR! 403 Forbidden: npmuser-core@latest npm ERR! A complete log of this run can be found in: npm ERR! /Users/user/.npm/_logs/2017-07-02T12_20_14_834Z-debug.log ``` -------------------------------- ### Install Verdaccio CLI Globally Source: https://verdaccio.org/docs/installation Installs the Verdaccio command-line interface globally on your system. Ensure you have Node.js and a compatible npm, yarn, or pnpm version installed. This command is essential for running Verdaccio locally. ```shell npm install -g verdaccio ``` ```shell yarn global add verdaccio ``` ```shell pnpm install -g verdaccio ``` -------------------------------- ### Configure Basic htpasswd Authentication in Verdaccio Source: https://verdaccio.org/docs/plugin-auth This snippet shows the basic configuration for using the htpasswd authentication plugin in Verdaccio. It specifies the path to the htpasswd file for storing user credentials. This is a common starting point for simple authentication setups. ```yaml auth: htpasswd: file: ./htpasswd ``` -------------------------------- ### Verdaccio UI Theme Options Example (JSON) Source: https://verdaccio.org/docs/next/plugin-theme An example of the `__VERDACCIO_BASENAME_UI_OPTIONS` object available in the browser global context. This object defines various settings for the Verdaccio UI, such as dark mode, base URL, primary color, package managers, login status, logo, title, scope, and language. ```json { "darkMode": false, "basename": "/", "base": "https://registry.my.org/", "primaryColor": "#4b5e40", "version": "5.20.1", "pkgManagers": [ "yarn", "pnpm", "npm" ], "login": true, "logo": "", "title": "Verdaccio Registry", "scope": "", "language": "es-US" } ``` -------------------------------- ### Verdaccio Plugin Package JSON Example Source: https://verdaccio.org/docs/plugin-middleware Example content of a `package.json` file generated for a Verdaccio middleware plugin. It includes the plugin's name and description, indicating it's an 'awesome middleware plugin'. ```json { "name": "verdaccio-plugin-custom-endpoint", "version": "0.0.1", "description": "awesome middleware plugin", ... } ``` -------------------------------- ### Configure Bun Project Registry Source: https://verdaccio.org/docs/next/setup-bun Set a specific registry for a Bun project by creating a `bunfig.toml` file. This ensures installations are pulled from the configured local Verdaccio registry. Dependencies are managed through this file. ```toml [install] registry = "http://localhost:4873" ``` -------------------------------- ### Install Verdaccio Authentication Plugin Source: https://verdaccio.org/docs/plugins Installs a Verdaccio authentication plugin globally using npm. This is a prerequisite for configuring and using custom authentication methods. ```bash $> npm install --global verdaccio-activedirectory ``` -------------------------------- ### Verdaccio Server API Functions (JavaScript and .NET) Source: https://verdaccio.org/docs/node-api This section covers the API functions provided by the `verdaccio-server` library for managing the Verdaccio server. It includes methods for starting, stopping, listing, and showing server status, as well as service installation and management for Windows environments. ```javascript // js import * as verdaccioServer from 'verdaccio-server'; verdaccioServer.start(); verdaccioServer.stop(); verdaccioServer.list(); verdaccioServer.stopAll(); verdaccioServer.show(); verdaccioServer.cli(); // windows .net2 verdaccioServer.serviceInstall(); verdaccioServer.serviceUninstall(); verdaccioServer.serviceStart(); verdaccioServer.serviceStop(); verdaccioServer.serviceRestart(); ``` -------------------------------- ### Configure Verdaccio with object and self_path workaround Source: https://verdaccio.org/docs/next/verdaccio-programmatically This example demonstrates how to use `runServer` with a configuration object, including the workaround for setting `self_path` in versions prior to v6. It uses `parseConfigFile` to load configuration and manually assigns `self_path` before starting the server. ```javascript const { runServer, parseConfigFile } = require('verdaccio'); const configPath = join(__dirname, './config.yaml'); const c = parseConfigFile(configPath); // workaround // on v5 the `self_path` still exists and will be removed in v6 c.self_path = 'foo'; runServer(c).then(() => {}); ``` -------------------------------- ### Install Sinopia Memory Plugin (Legacy) Source: https://verdaccio.org/docs/next/plugins Installs the `sinopia-memory` plugin globally using npm. This is a legacy plugin for in-memory storage, demonstrating backward compatibility with older Sinopia plugins. ```bash $> npm install --global sinopia-memory ``` -------------------------------- ### Install Verdaccio Theme Plugin Source: https://verdaccio.org/docs/plugins Installs a Verdaccio theme plugin globally using npm. This allows customization of the Verdaccio user interface. ```bash npm install --global verdaccio-theme-dark ``` -------------------------------- ### Install Verdaccio CLI Globally (pnpm) Source: https://verdaccio.org/docs/next/installation Installs the Verdaccio command-line interface globally using pnpm. Requires Node.js v18 or higher. This installation method makes the 'verdaccio' command available across your projects. ```bash pnpm install -g verdaccio@next-7 ``` -------------------------------- ### Install Forever Globally (npm) Source: https://verdaccio.org/docs/next/server-configuration Installs the 'forever' Node.js package globally, enabling its use for managing Node.js processes. Requires npm and sudo privileges. ```bash $ sudo npm install -g forever ``` -------------------------------- ### Full ES5 Authentication Plugin Implementation Source: https://verdaccio.org/docs/next/plugin-auth This provides a complete example of an authentication plugin written in ES5 JavaScript. It defines an `Auth` constructor that initializes user data and logger, and an `authenticate` method that uses an LDAP client for authentication. The configuration example shows how to set up an htpasswd authentication method. ```javascript function Auth(config, stuff) { var self = Object.create(Auth.prototype); self._users = {}; // config for this module self._config = config; // verdaccio logger self._logger = stuff.logger; // pass verdaccio logger to ldapauth self._config.client_options.log = stuff.logger; return self; } Auth.prototype.authenticate = function (user, password, callback) { var LdapClient = new LdapAuth(self._config.client_options); .... LdapClient.authenticate(user, password, function (err, ldapUser) { ... var groups; ... callback(null, groups); }); }; module.exports = Auth; ``` ```yaml auth: htpasswd: file: ./htpasswd ``` -------------------------------- ### Install Protected Package in Verdaccio (CLI) Source: https://verdaccio.org/docs/next/packages Demonstrates the command to install a package that is protected by specific access rules in Verdaccio, and the expected output if access is denied. ```bash $ npm install npmuser-core npm install npmuser-core npm ERR! code E403 npm ERR! 403 Forbidden: npmuser-core@latest npm ERR! A complete log of this run can be found in: npm ERR! /Users/user/.npm/_logs/2017-07-02T12_20_14_834Z-debug.log ``` -------------------------------- ### Start Verdaccio Programmatically with Node.js API Source: https://verdaccio.org/docs/node-api This snippet demonstrates how to start a Verdaccio server programmatically using the Node.js API. It involves defining a configuration object with settings for storage, authentication, uplinks, and package access, then calling the `startServer` function with the configuration and port. ```javascript const startServer = require("verdaccio").default; let config = { storage: "./storage", auth: { htpasswd: { file: "./htpasswd" } }, uplinks: { npmjs: { url: "https://registry.npmjs.org/", } }, self_path: "./", packages: { "@*/*": { access: "$all", publish: "$authenticated", proxy: "npmjs", }, "**": { proxy: "npmjs" } }, log: { type: "stdout", format: "pretty", level: "http", }; startServer( config, 6000, undefined, "1.0.0", "verdaccio", (webServer, addrs) => { webServer.listen( addrs.port || addrs.path, addrs.host, () => { console.log(`verdaccio running on : ${addrs.host}:${addrs.port}`); } ); } ); ``` -------------------------------- ### Start Verdaccio with Forever Source: https://verdaccio.org/docs/next/server-configuration Starts the Verdaccio process using the 'forever' tool to ensure it runs continuously. Assumes Verdaccio has been run at least once to generate config. ```bash $ forever start `which verdaccio` ``` -------------------------------- ### Configure Verdaccio Service with NSSM (Windows) Source: https://verdaccio.org/docs/windows Sets up Verdaccio as a Windows service using NSSM. Requires NSSM to be downloaded and its path added to the system's PATH environment variable. Assumes Node.js is in the system path and Verdaccio is installed in `c:\verdaccio`. ```bash nssm install verdaccio sc start verdaccio ``` -------------------------------- ### Install Package with Specific Registry (npm) Source: https://verdaccio.org/docs/next/what-is-verdaccio Install a package using npm, specifying the Verdaccio registry for this particular command. This is useful for testing or temporary configuration. ```bash npm install lodash --registry http://localhost:4873 ``` -------------------------------- ### Install Verdaccio CLI Globally (npm) Source: https://verdaccio.org/docs/next/installation Installs the Verdaccio command-line interface globally using npm. Requires Node.js v18 or higher. This command makes the 'verdaccio' executable available system-wide. ```bash npm install -g verdaccio@next-7 ``` -------------------------------- ### Install Verdaccio Dark Theme Plugin Source: https://verdaccio.org/docs/next/plugins Installs the `verdaccio-theme-dark` plugin globally using npm. This plugin applies a dark theme to the Verdaccio UI. ```bash npm install --global verdaccio-theme-dark ``` -------------------------------- ### Install Verdaccio UI Components (npm) Source: https://verdaccio.org/docs/next/ui-components Installs the Verdaccio UI components as a development dependency. This package provides reusable React components for building user interfaces. It's recommended to use the specific '-next' version for the Next release. ```bash npm i -D @verdaccio/ui-components@6-next ``` -------------------------------- ### Scoped Plugin Configuration Example Source: https://verdaccio.org/docs/next/plugins Demonstrates how to configure scoped plugins in Verdaccio's `config.yaml`. This allows for organization-specific plugins using `@my-org/` naming. ```yaml auth: '@my-org/auth-awesome-plugin': foo: some value bar: another value store: '@my-org/store-awesome-plugin': foo: some value bar: another value middleware: '@my-org/middleware-awesome-plugin': foo: some value bar: another value ``` -------------------------------- ### Install Package with Specific Registry Source: https://verdaccio.org/docs/next/installation Installs an npm package using a specific registry, overriding the default configured registry. Useful for temporary use of the Verdaccio instance. ```bash npm install --registry http://localhost:4873 ``` -------------------------------- ### Add Verdaccio Helm Repository Source: https://verdaccio.org/docs/installation Adds the official Verdaccio Helm chart repository to your Helm client. This allows you to easily install and manage Verdaccio on Kubernetes. ```shell $ helm repo add verdaccio https://charts.verdaccio.org $ helm repo update $ helm install verdaccio/verdaccio ``` -------------------------------- ### Building Verdaccio Plugins with Native Dependencies in Docker Source: https://verdaccio.org/docs/next/docker This Dockerfile snippet demonstrates how to build plugins with native dependencies. It uses a multi-stage build, first installing the plugin in a builder stage and then copying the installed plugin into the final Verdaccio image. Ensure the base image matches the Verdaccio Dockerfile for compatibility. ```dockerfile FROM node:lts-alpine as builder RUN mkdir -p /verdaccio/plugins \n && cd /verdaccio/plugins \n && npm install --global-style --no-bin-links --omit=optional verdaccio-auth-memory@latest FROM verdaccio/verdaccio:6 ADD docker.yaml /verdaccio/conf/config.yaml COPY --chown=$VERDACCIO_USER_UID:root --from=builder \n /verdaccio/plugins/node_modules/verdaccio-auth-memory \n /verdaccio/plugins/verdaccio-auth-memory ``` -------------------------------- ### Install Verdaccio Helm Chart Source: https://verdaccio.org/docs/next/kubernetes Deploys the Verdaccio Helm chart using 'npm' as the release name. This command installs Verdaccio with default configurations. ```bash helm install npm verdaccio/verdaccio ``` -------------------------------- ### Run and Configure Verdaccio Service Source: https://verdaccio.org/docs/next/amazon This section covers running Verdaccio initially to generate configuration files, editing `config.yaml` to listen on all interfaces and set authentication/user limits, and then starting Verdaccio as a background service using PM2. ```bash verdaccio # Edit ~/.config/verdaccio/config.yaml or ~/verdaccio/config.yaml # Add to listen: # - 0.0.0.0:4873 # Replace "access: $all" with "access: $authenticated" # (Optional) Replace "#max_users: 1000" with "max_users: 1" pm2 start verdaccio ``` -------------------------------- ### Verdaccio Theme Configuration (YAML) Source: https://verdaccio.org/docs/next/plugin-theme Example of how to configure a custom theme plugin in Verdaccio's configuration file. This example shows how to enable the 'dark' theme and pass custom options to it. ```yaml theme: dark: option1: foo option2: bar ``` -------------------------------- ### Find Executable Paths (which) Source: https://verdaccio.org/docs/next/server-configuration Utility command to display the full path of executable commands. Useful for verifying installation locations of tools like 'forever' and 'verdaccio'. ```bash $ which forever $ which verdaccio ``` -------------------------------- ### Install Legacy Sinopia Plugin Source: https://verdaccio.org/docs/plugins Installs a legacy Sinopia plugin globally using npm. While deprecated, some Sinopia plugins may still be compatible with older Verdaccio versions. ```bash $> npm install --global sinopia-memory ``` -------------------------------- ### Display Verdaccio Version Information Source: https://verdaccio.org/docs/next/cli This command displays the currently installed version of Verdaccio. It's a simple utility for verifying your Verdaccio installation. ```shell verdaccio --version ``` -------------------------------- ### Add Verdaccio Helm Repository Source: https://verdaccio.org/docs/next/installation Adds the official Verdaccio Helm chart repository to your Helm configuration. This allows you to install Verdaccio on Kubernetes using Helm. ```bash $ helm repo add verdaccio https://charts.verdaccio.org $ helm repo update $ helm install registry --set image.tag=nightly-master verdaccio/verdaccio ``` -------------------------------- ### Install Specific Verdaccio Version with Helm Source: https://verdaccio.org/docs/next/kubernetes Deploys a specific version of the Verdaccio Helm chart. The `--set image.tag` option allows you to specify the desired image tag for installation. ```bash helm install npm --set image.tag=3.13.1 verdaccio/verdaccio ``` -------------------------------- ### Generate a Middleware Plugin Source: https://verdaccio.org/docs/plugin-storage Instructions and example command for generating a new Verdaccio plugin, specifically a storage plugin, using the Yeoman generator. ```APIDOC ## Generate a Middleware Plugin To create a new Verdaccio plugin, you can use the Yeoman generator. ### Command Run the following command in your terminal: ```bash yo verdaccio-plugin ``` ### Example Interaction The generator will prompt you for details about your plugin, such as its name, language, type (storage in this case), description, and author information. ``` ➜ yo verdaccio-plugin ? What is the name of your plugin? custom-endpoint ? Select Language typescript ? What kind of plugin you want to create? storage ? Please, describe your plugin awesome storage plugin ? GitHub username or organization myusername ? Author's Name Juan Picado ? Author's Email jotadeveloper@gmail.com ? Key your keywords (comma to split) verdaccio,plugin,storage,awesome,verdaccio-plugin I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself. ``` This process will scaffold the necessary files and dependencies for your new plugin. ``` -------------------------------- ### Verdaccio Server API Methods in JavaScript Source: https://verdaccio.org/docs/next/node-api This snippet showcases various methods available from the 'verdaccio-server' package for managing a Verdaccio instance. It includes functions for starting, stopping, listing, and manipulating the server and its services. ```javascript // js import * as verdaccioServer from 'verdaccio-server'; verdaccioServer.start(); verdaccioServer.stop(); verdaccioServer.list(); verdaccioServer.stopAll(); verdaccioServer.show(); verdaccioServer.cli(); // windows .net2 verdaccioServer.serviceInstall(); verdaccioServer.serviceUninstall(); verdaccioServer.serviceStart(); verdaccioServer.serviceStop(); verdaccioServer.serviceRestart(); ``` -------------------------------- ### npm Install Failure due to Forbidden Access (CLI) Source: https://verdaccio.org/docs/next/protect-your-dependencies This example demonstrates a typical error message when a user ('teamD') attempts to install a protected package ('my-company-core') that they do not have permission to access. The 'E403' error code indicates a forbidden resource. ```shell ➜ npm install my-company-core npm ERR! code E403 npm ERR! 403 Forbidden: webpack-1@latest ``` -------------------------------- ### Create User with npm adduser Source: https://verdaccio.org/docs/next/setup-npm Creates a new user and logs in to the npm registry using the `adduser` command. This is the traditional method for user creation and authentication. Note that after npm@9, `adduser` and `login` commands function separately. ```bash npm adduser --registry http://localhost:4873 ``` -------------------------------- ### Install Yeoman and Verdaccio Plugin Generator Source: https://verdaccio.org/docs/next/plugin-generator Installs the necessary Yeoman command-line tool and the Verdaccio custom plugin generator. A specific version of Yeoman (v4) is required for compatibility with the Verdaccio generator. ```bash npm install -g yo@4 ``` ```bash npm i -g generator-verdaccio-plugin ``` -------------------------------- ### Generate a Middleware Plugin Source: https://verdaccio.org/docs/next/plugin-middleware Guides users on generating a new middleware plugin using the Yeoman generator. ```APIDOC ## Generate a Middleware Plugin ### Description Use the Verdaccio plugin generator (`yo verdaccio-plugin`) to scaffold a new middleware plugin. Follow the interactive prompts to configure your plugin. ### Command ```bash yo verdaccio-plugin ``` ### Interactive Prompts 1. **What is the name of your plugin?** (e.g., `custom-endpoint`) 2. **Select Language** (e.g., `typescript`) 3. **What kind of plugin you want to create?** (`middleware`) 4. **Please, describe your plugin** (e.g., `awesome middleware plugin`) 5. **GitHub username or organization** 6. **Author's Name** 7. **Author's Email** 8. **Key your keywords** (comma-separated) ### Post-Generation Steps After the generator completes and installs dependencies, navigate to your new plugin's directory. ```bash cd verdaccio-plugin-custom-endpoint cat package.json ``` **Note:** Middleware plugins are registered after built-in endpoints, preventing overriding of existing ones. ``` -------------------------------- ### Helm: Initialize Helm Controller (Tiller) Source: https://verdaccio.org/docs/kubernetes This command initializes the Helm controller, known as Tiller, which is necessary for using Helm to manage Kubernetes applications. Ensure Tiller is set up before proceeding with Helm installations. ```shell helm init ``` -------------------------------- ### Pull Verdaccio Docker Image Source: https://verdaccio.org/docs/docker This command pulls the latest pre-built Docker image for Verdaccio from Docker Hub. No specific version or dependencies are required, and it's a straightforward way to get started. ```bash docker pull verdaccio/verdaccio ``` -------------------------------- ### Verdaccio package.json configuration Source: https://verdaccio.org/docs/iss-server Defines the project's metadata and dependencies, specifically listing Verdaccio as a required package. This file is essential for npm to manage the project's packages. ```json { "name": "iisnode-verdaccio", "version": "1.0.0", "description": "Hosts verdaccio in iisnode", "main": "start.js", "dependencies": { "verdaccio": "^3.11.0" } } ``` -------------------------------- ### Apache Configuration with Gzip Disabled Source: https://verdaccio.org/docs/next/reverse-proxy An example of an Apache virtual host configuration that includes the directive to disable gzip compression. This combined configuration aims to resolve 'invalid checksum' issues while maintaining the reverse proxy setup for Verdaccio. ```apache AllowEncodedSlashes NoDecode SetEnv no-gzip 1 ProxyPass /npm http://127.0.0.1:4873 nocanon ProxyPassReverse /npm http://127.0.0.1:4873 ``` -------------------------------- ### Configure Verdaccio Docker HTTPS Environment Variables Source: https://verdaccio.org/docs/ssl Sets environment variables for the Verdaccio Docker image to enable HTTPS. `VERDACCIO_PROTOCOL` should be set to 'https', and `VERDACCIO_PORT` can be specified if not using the default port. ```bash export VERDACCIO_PROTOCOL=https export VERDACCIO_PORT=4873 ``` -------------------------------- ### Implement Access Control Callback (JavaScript) Source: https://verdaccio.org/docs/next/plugin-auth An example implementation of the `allow_access` method within an authentication plugin. It checks if a user is allowed to access a package and uses the callback to return the result. ```javascript allow_access(user: RemoteUser, pkg: PackageAccess, cb: Callback): void { const isAllowed: boolean = checkAction(user, pkg); callback(null, isAllowed) } ``` -------------------------------- ### Handle Add User Success Callback (JavaScript) Source: https://verdaccio.org/docs/next/plugin-auth Example of the callback for a successful user addition. It's called with `null` for the error and `true` to indicate success. ```javascript callback(null, true); ``` -------------------------------- ### Configure Publish Registry in package.json Source: https://verdaccio.org/docs/installation Specifies the Verdaccio registry URL within the publishConfig section of your package.json file. This setting is applied specifically when publishing packages. ```json { "publishConfig": { "registry": "http://localhost:4873" } } ``` -------------------------------- ### Verdaccio Invalid Checksum Error Message Source: https://verdaccio.org/docs/next/reverse-proxy An example of error messages that may appear in the console when 'npm install' fails due to an invalid checksum, often caused by gzip compression issues. This highlights the problem that the Apache configuration change aims to solve. ```text npm WARN tar TAR_ENTRY_INVALID checksum failure npm WARN tar zlib: incorrect data check ``` -------------------------------- ### Manage Verdaccio with PM2 Source: https://verdaccio.org/docs/next/amazon Commands for managing the Verdaccio service using PM2, including listing status, stopping, deleting, and configuring it to start on system reboot. This ensures the registry is available after server restarts. ```bash pm2 list pm2 stop verdaccio pm2 delete verdaccio pm2 startup # Copy and paste the output command from pm2 startup # Find verdaccio path: which verdaccio pm2 start /home/ubuntu/.nvm/versions/node/v17.1.0/bin/verdaccio # Use the actual path from 'which verdaccio' pm2 status pm2 save ``` -------------------------------- ### Generate a Middleware Plugin Source: https://verdaccio.org/docs/next/plugin-storage Information on generating a new Verdaccio middleware plugin using the `yo verdaccio-plugin` command. This process guides users through creating custom storage plugins. ```APIDOC ## Generate a Middleware Plugin ### Description Use the `yo verdaccio-plugin` command to generate a new middleware plugin, including custom storage plugins. ### Usage Run the following command in your terminal: ```bash ➜ yo verdaccio-plugin ``` The generator will prompt you for details such as the plugin name, language, type (storage), description, GitHub username, author details, and keywords. ``` -------------------------------- ### Basic Uplinks Configuration (YAML) Source: https://verdaccio.org/docs/next/uplinks An example of defining multiple uplinks in Verdaccio configuration. Each uplink requires a unique name and a URL to an external registry. Optional properties like timeout can also be specified. ```yaml uplinks: npmjs: url: https://registry.npmjs.org/ server2: url: http://mirror.local.net/ timeout: 100ms server3: url: http://mirror2.local.net:9000/ baduplink: url: http://localhost:55666/ ``` -------------------------------- ### Deno Cache Information and Clearing Source: https://verdaccio.org/docs/setup-deno This snippet shows how to retrieve cache information for Deno, including the location of various caches like remote modules and npm modules. It also provides an example command to remove the local cache specifically for a Verdaccio registry (defaulting to localhost_4873). This is useful for troubleshooting and ensuring fresh module installations. ```bash > deno info DENO_DIR location: /Users/user/Library/Caches/deno Remote modules cache: /Users/user/Library/Caches/deno/deps npm modules cache: /Users/user/Library/Caches/deno/npm Emitted modules cache: /Users/user/Library/Caches/deno/gen Language server registries cache: /Users/user/Library/Caches/deno/registries Origin storage: /Users/user/Library/Caches/deno/location_data ``` ```bash // for MAC OS users (other OS may vary) rm -Rf /Users/user/Library/Caches/deno/npm/localhost_4873 ``` -------------------------------- ### Login with npm login Source: https://verdaccio.org/docs/next/setup-npm Logs in to the npm registry. In npm versions 9 and later, the `login` command is separate from user creation and primarily handles authentication. It can be used with the `--registry` flag to target a specific registry like Verdaccio. ```bash npm login --registry http://localhost:4873 ``` -------------------------------- ### Generate SSL Certificates using OpenSSL Source: https://verdaccio.org/docs/next/ssl This snippet shows the OpenSSL commands to generate RSA private key, a certificate signing request (CSR), and the self-signed SSL certificate. These files are essential for serving Verdaccio over HTTPS. ```bash $ openssl genrsa -out /Users/user/.config/verdaccio/verdaccio-key.pem 2048 $ openssl req -new -sha256 -key /Users/user/.config/verdaccio/verdaccio-key.pem -out /Users/user/.config/verdaccio/verdaccio-csr.pem $ openssl x509 -req -in /Users/user/.config/verdaccio/verdaccio-csr.pem -signkey /Users/user/.config/verdaccio/verdaccio-key.pem -out /Users/user/.config/verdaccio/verdaccio-cert.pem ```