What is a .npmrc file?
npm Configuration File · Code and data · npm (GitHub) · 2010
An .npmrc file configures the npm package manager: which registry to use, authentication tokens, proxy settings and install behaviour. It can sit in a project, in your home folder, or globally.
What is a .npmrc file used for?
The format is simple key=value text, for example registry=https://registry.npmjs.org/ or save-exact=true. npm merges four levels: per-project, per-user, global and built-in, with the project file winning.
Project .npmrc files matter in companies because they point installs at private registries. They can also hold auth tokens, which is why a leaked .npmrc is a real security incident; tokens belong in environment variables where possible.
How to open a .npmrc file
The .npmrc format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .npmrc file.
Windows
- any text editor
- VS Code
macOS
- any text editor
- VS Code
Linux
- any text editor
- VS Code
.npmrc file signature (magic bytes)
Programs recognise a .npmrc file by the bytes at the start of the file, not by its name. These are the signatures for npmrc.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | plain text; no fixed magic bytes |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .npmrc file?
An .npmrc file configures the npm package manager: which registry to use, authentication tokens, proxy settings and install behaviour. It can sit in a project, in your home folder, or globally.
Where is my .npmrc file?
There can be several: one in the project root, a per-user one in your home directory, and a global one next to the npm install. npm config list shows what applies.
Should I commit .npmrc to git?
A project .npmrc with registry settings, yes. One containing an _authToken, never; keep tokens in the per-user file or inject them via environment variables in CI.
How do I point npm at a private registry?
Add a line like registry=https://your-registry.example/ to the project's .npmrc, optionally scoped, for example @yourorg:registry=... for one namespace only.
Related formats
Sources
Details on this page were checked against authoritative references: