.npmrc

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.

Category
Code and data
MIME type
Type
Plain text
Is a .npmrc file safe to open? Mostly safe: it is plain text and does not execute. Treat it as sensitive though, because it can contain registry auth tokens that should never be committed or shared.

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.

What opens 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.

Windows

  • any text editor
  • VS Code

macOS

  • any text editor
  • VS Code

Linux

  • any text editor
  • VS Code

Open a .npmrc file step by step

  1. Confirm the file really is a .npmrc. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with any text editor or VS Code.
  3. On Mac, use any text editor or VS Code.
  4. On Linux, try any text editor or VS Code.
  5. Still stuck? Search for a dedicated npmrc viewer rather than a generic one.

Why can't I open my .npmrc file?

Almost always because no installed app understands npmrc. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .npmrc at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

npmrc has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

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. How sources are ranked and what is deliberately left out is set out in the methodology.