EckherInsightsToolsContact
Eckher
Your guide to what's next.
Eckher
English
Home › Eckher Insights › Authenticating to an npm registry
Dec 31, 2019

Authenticating to an npm registry

How to authenticate to an npm registry?

To load private packages from the npm package registry or a private registry using npm install, the npm client needs to authenticate to the registry.

npm uses the _authToken values from the .npmrc file to authenticate to each registry. The following .npmrc for example, makes npm use TOKEN to authenticate to the npm registry:

//registry.npmjs.org/:_authToken=TOKEN

The .npmrc file is stored in the home directory and the values can be viewed and edited using npm config. The values can be overridden by the .npmrc configuration in the project root.

Alternatively, the user can log in to a registry using npm login. This command requires entering the username and password, but all it does is obtain the authentication token and save it to .npmrc. Saving the token to .npmrc directly is a great way to "log in" to the npm registry non-interactively which is useful in CI/CD workflows that run npm install inside Docker.

Cover
See also
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".
Loading npm dependencies from multiple registries
How to add npm dependencies from multiple package registries?
Creating a JavaScript library with webpack
How to bundle a JavaScript library with webpack?
Publishing an npm package to GitHub Packages
How to publish an npm package to GitHub Packages?
Signed exchanges
What are signed exchanges and how to implement them?
Working with ChemDraw JS
ChemDraw JS makes it possible to create, view, and edit chemical structures in the browser.
How to run a JSX script?
Executing .jsx files with command line.
Eckher
Your guide to what's next.
Copyright © 2021 Eckher. Various trademarks held by their respective owners.