.npmrc

What is a .npmrc file?

npm configuration — package registry, auth tokens, install behaviour. Sets the rules for how `npm install` works in this project.

Use caution
Type Code
By npm Inc.
MIME text/plain

Drop any file to identify it

No upload. No signup. No sending your file halfway across the internet.
We tell you what it is, right here in your browser.

What is it

The .npmrc file configures npm behaviour. Place one at the root of a project and every `npm install` run from that directory follows its rules. Common settings: `registry=https://npm.your-company.com/` to point at a private registry, `save-exact=true` to pin exact versions instead of caret ranges, `legacy-peer-deps=true` to opt out of npm 7+'s strict peer dependency enforcement, and `engine-strict=true` to fail installs that don't match the engines field in package.json.

There are three .npmrc locations and they layer: the project's `.npmrc` overrides the user's `~/.npmrc`, which overrides the global `/etc/npmrc`. The user .npmrc is where your auth token lives — `//registry.npmjs.org/:_authToken=${NPM_TOKEN}` — so npm publish knows who you are. The project .npmrc is where shared team settings live. Never commit auth tokens in a project .npmrc; use `${ENV_VAR}` interpolation and supply the actual token via environment variable in CI.

The syntax is INI-style key=value pairs, one per line. The full list of settings is at docs.npmjs.com/cli/v10/configuring-npm/npmrc, and `npm config list -l` prints every effective config including defaults. .npmrc also affects pnpm and Yarn Classic (Yarn Berry uses .yarnrc.yml instead), making it the closest thing to a universal JS package manager config in projects that haven't picked a side.

Technical details
Full Name
.npmrc
MIME Type
text/plain
Developer
npm Inc.
Magic Bytes
N/A
Safety
.npmrc requires caution. May contain auth tokens for private registries. Never commit a project .npmrc with hardcoded tokens — use environment variable interpolation instead.
What opens it
Any text editor
FREE All
VS Code
FREE All
FAQ
Should I commit my project's .npmrc?
Yes, if it contains shared settings like registry URL or save-exact. No, if it contains auth tokens. The pattern is to commit the .npmrc with `${NPM_TOKEN}` placeholders and provide the actual token via the NPM_TOKEN environment variable in CI and developer machines.
What's the difference between .npmrc and package.json?
package.json describes the project (dependencies, scripts, metadata). .npmrc configures npm itself (registry, install behaviour, auth). Both can pin a Node version — package.json via `engines.node`, .npmrc via `engine-strict=true` to enforce it. They work together.
Related formats