Skip to content

WTF is an .npmrc file and how to configure npm with npmrc?

In this article, we will discuss the basics of npm configuration file called npmrc and the various ways npmrc can be configured.

One of the most important features of the npm CLI is that its highly configurable. NPM provides an great levels of configurability that enables everyone from huge enterprises to individual developers to use it effectively.

One thing that enables this high-configurability is the .npmrc file. .npmrc is the configuration file that npm allows to be used globally or user level or project level to optimize your npm environment.

npmrc can be configured in four different locations

  1. Globally
  2. Per user
  3. Per project
  4. In-built

Global npmrc

Global npmrc located at /etc/npmrc is a list of key-values which might be used like environment variables

Per user npmrc

You can configure user-level npmrc by creating a .npmrc file under the home directory.

Per project npmrc

This can be configured at the root of your project which applies only for your project

In-built npmrc

This is an unchangeable npm configuration which keeps npm consistent.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.