LinuxCommandLibrary

nrm

Manage and switch between npm registries

TLDR

List all registries

$ nrm ls
copy

Change to a particular registry
$ nrm use [registry]
copy

Show the response time for all registries
$ nrm test
copy

Add a custom registry
$ nrm add [registry] [url]
copy

Delete a registry
$ nrm del [registry]
copy

SYNOPSIS

nrm <command> [<options>]
nrm <command> [<arguments>]

PARAMETERS

ls
    Lists all available npm registries, highlighting the currently active one.

use <registry_name>
    Switches the current npm registry to the specified <registry_name>.

add <name> <url> [<home_url>]
    Adds a new custom npm registry with the given <name> and <url>. An optional <home_url> can be provided.

del <name>
    Deletes a custom npm registry specified by <name>.

test [<registry_name>]
    Tests the response time of all available registries or a specific <registry_name> if provided.

current
    Displays the name of the currently active npm registry.

--version, -v
    Shows the installed version of nrm.

--help, -h
    Displays help information for nrm or a specific subcommand.

DESCRIPTION

The nrm (npm registry manager) command-line utility is a powerful tool for Node.js developers, designed to simplify the process of switching between different npm registries. In environments where access to the default npm registry (registry.npmjs.org) might be slow, restricted, or when working with private or mirror registries, nrm provides an efficient solution.

Instead of manually editing .npmrc configuration files, nrm allows users to list available registries, quickly switch to a preferred one, add custom registries, and even test their response times. It comes pre-configured with several common registries like npm, cnpm, taobao, and others, offering out-of-the-box flexibility. This makes it particularly useful for developers in regions with unreliable network access to the global npm registry or for those needing to integrate with internal corporate registries.

nrm is not a core Linux command but a Node.js package, installed globally via npm. It alters the global npm configuration, ensuring that subsequent npm install or npm publish commands interact with the currently selected registry.

CAVEATS

nrm is a Node.js package and requires Node.js and npm to be installed on your system. It is typically installed globally using npm install -g nrm.

Changes made by nrm affect the global npm configuration (~/.npmrc or equivalent), meaning all subsequent npm commands will use the selected registry. Exercise caution when adding or using untrusted registries, as this could have security implications for your package installations.

INSTALLATION

To install nrm, ensure Node.js and npm are installed, then run: npm install -g nrm

CONFIGURATION

nrm stores its configuration, including custom registries, in a file typically located at ~/.nrmrc on Unix-like systems. This file is automatically managed by nrm commands.

HISTORY

nrm was created by Pana Wang (Pana) to address the common pain point of managing multiple npm registries. It emerged as a pragmatic solution for developers, especially those facing network latency to the official npm registry or working within corporate environments requiring specific internal registries. Its open-source nature and straightforward functionality have contributed to its widespread adoption within the Node.js community as a de facto standard for registry switching.

SEE ALSO

npm(1), node(1), yarn(1), pnpm(1)

Copied to clipboard