Understanding .npmrc file

Published 
JavaScript

The .npmrc file is a configuration file for npm. It allows you to specify various settings that control the behavior of npm, such as the location of the npm registry, the prefix for global installations, and authentication details for private registries.

This file is usually located within this path on MacOS: ~/.npmrc and contains the following data:

//registry.npmjs.org/:_authToken=***
//nexus.domain.kz/repository/custom-npm/:_authToken=***
registry=https://registry.npmjs.org/
  • registry - sets the URL of the npm registry from which packages should be installed. Can be changed using the following command: npm config set registry https://registry.npmjs.org/
  • //registry.npmjs.org/:_authToken=*** - sets the authentication token for the npm registry, which is necessary if you're using private packages.

You can check if you're currently logged-in in your current registry by using this command: npm whoami, if you're not, then you cal login: npm login. After you successfully logged-in using npm login, an _authToken will be automatically added to your .npmrc file.