Skip to content

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.

Advertisements

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.

Advertisements

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
Advertisements

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.

Advertisements

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.

We have already discussed how to congifure npmrc with a private repository.

See also  Missing write access to /usr/local/lib/node_modules - npm error - How to fix?

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.