Loading npm dependencies from multiple registries

package.json does not support explicitly specifying which registries to route package requests to for its dependencies and devDependencies.

It is possible that the project uses dependencies from the npm registry and one or more GitHub Packages.

By default, npm install loads the modules from the npm package registry, https://registry.npmjs.org/, because this is the default value of "registry" in the npm config (a line in .npmrc or "npm config get registry"):

registry=https://registry.npmjs.org/

If this value is changed to say, "https://npm.pkg.github.com", npm install will try to load all project dependencies from GitHub Packages. It is possible, however, to override this value for a specific @SCOPE using the following syntax:

@SCOPE:registry=https://npm.pkg.github.com/

For instance, if the project has the following package.json:

{
  "dependencies": {
    "@octo-org/octo-app": "1.0.0",
    "react": "^16.9.0"
  }
}

and .npmrc:

@octo-org:registry=https://npm.pkg.github.com/

then npm install will download react from the npm registry and @octo-org/octo-app from GitHub Packages.

This configuration allows one registry to host multiple scopes, but a scope can only point to a single registry.

See also

Leskoff "Hello, World!" Code Snippet Poster image
"Hello, World!" Code Snippet Poster, JavaScript Programming Language
$14.99

A poster featuring the "Hello, World!" program in JavaScript programming language.

Leskoff буклет IPA Transcription Poster image
буклет IPA Transcription Poster
$14.99

A poster featuring the phonetic transcription of "буклет" in the International Phonetic Alphabet (IPA).

Leskoff Big Phonetic Transcriptions image
Big Phonetic Transcriptions
$29.99

A collection of phonetic transcriptions showcasing the beauty of phonetic notation.

Leskoff Cyclohexane Molecule Poster image
Cyclohexane Molecule Poster, 2D Structure, English-Labeled
$19.99

A poster featuring the 2D structure of the cyclohexane molecule.

npm exec: A new way to run commands from npm packages

npm v7 has introduced the new npm exec command which, like npx, can be used to run npm scripts "on the fly".

Generating data URLs in JavaScript

How to generate data URLs in JavaScript?

Receiving email with Node.js

How to receive email in Node.js?

TensorFlow.js and linear regression

Building and training simple linear regression models in JavaScript using TensorFlow.js.

Walking a directory in Node.js

How to list all files recursively within a directory tree in Node.js?

All prices listed are in United States Dollars (USD). Visual representations of products are intended for illustrative purposes. Actual products may exhibit variations in color, texture, or other characteristics inherent to the manufacturing process. The products' design and underlying technology are protected by applicable intellectual property laws. Unauthorized reproduction or distribution is prohibited.