.TH "NPMRC" "5" "November 2023" "9.2.0" .SH "NAME" \fBnpmrc\fR .SH Description .P npm gets its config settings from the command line, environment variables, .br and \fBnpmrc\fP files\. .P The \fBnpm config\fP command can be used to update and edit the contents of the .br user and global npmrc files\. .P For a list of available configuration options, see .br config\. .SH Files .P The four relevant files are: .RS 1 .IP \(bu 2 per\-project config file (/path/to/my/project/\.npmrc) .IP \(bu 2 per\-user config file (~/\.npmrc) .IP \(bu 2 global config file ($PREFIX/etc/npmrc) .IP \(bu 2 npm builtin config file (/path/to/npm/npmrc) .RE .P All npm config files are an ini\-formatted list of \fBkey = value\fP parameters\. .br Environment variables can be replaced using \fB${VARIABLE_NAME}\fP\|\. For .br example: .RS 2 .nf prefix = ${HOME}/\.npm\-packages .fi .RE .P Each of these files is loaded, and config options are resolved in priority .br order\. For example, a setting in the userconfig file would override the .br setting in the globalconfig file\. .P Array values are specified by adding "[]" after the key name\. For example: .RS 2 .nf key[] = "first value" key[] = "second value" .fi .RE .SS Comments .P Lines in \fB\|\.npmrc\fP files are interpreted as comments when they begin with a .br \fB;\fP or \fB#\fP character\. \fB\|\.npmrc\fP files are parsed by .br npm/ini, which specifies this comment syntax\. .P For example: .RS 2 .nf # last modified: 01 Jan 2016 ; Set a new registry for a scoped package @myscope:registry=https://mycustomregistry\.example\.org .fi .RE .SS Per\-project config file .P When working locally in a project, a \fB\|\.npmrc\fP file in the root of the .br project (ie, a sibling of \fBnode_modules\fP and \fBpackage\.json\fP) will set .br config values specific to this project\. .P Note that this only applies to the root of the project that you're running .br npm in\. It has no effect when your module is published\. For example, you .br can't publish a module that forces itself to install globally, or in a .br different location\. .P Additionally, this file is not read in global mode, such as when running .br \fBnpm install \-g\fP\|\. .SS Per\-user config file .P \fB$HOME/\.npmrc\fP (or the \fBuserconfig\fP param, if set in the environment or on .br the command line) .SS Global config file .P \fB$PREFIX/etc/npmrc\fP (or the \fBglobalconfig\fP param, if set above): This file .br is an ini\-file formatted list of \fBkey = value\fP parameters\. Environment .br variables can be replaced as above\. .SS Built\-in config file .P \fBpath/to/npm/itself/npmrc\fP .P This is an unchangeable "builtin" configuration file that npm keeps .br consistent across updates\. Set fields in here using the \fB\|\./configure\fP .br script that comes with npm\. This is primarily for distribution maintainers .br to override default configs in a standard and consistent manner\. .SH Auth related configuration .P The settings \fB_auth\fP, \fB_authToken\fP, \fBusername\fP and \fB_password\fP must all be .br scoped to a specific registry\. This ensures that \fBnpm\fP will never send .br credentials to the wrong host\. .P The full list is: .RS 1 .IP \(bu 2 \fB_auth\fP (base64 authentication string) .IP \(bu 2 \fB_authToken\fP (authentication token) .IP \(bu 2 \fBusername\fP .IP \(bu 2 \fB_password\fP .IP \(bu 2 \fBemail\fP .IP \(bu 2 \fBcertfile\fP (path to certificate file) .IP \(bu 2 \fBkeyfile\fP (path to key file) .RE .P In order to scope these values, they must be prefixed by a URI fragment\. .br If the credential is meant for any request to a registry on a single host, .br the scope may look like \fB//registry\.npmjs\.org/:\fP\|\. If it must be scoped to a .br specific path on the host that path may also be provided, such as .br \fB//my\-custom\-registry\.org/unique/path:\fP\|\. .RS 2 .nf ; bad config _authToken=MYTOKEN ; good config @myorg:registry=https://somewhere\-else\.com/myorg @another:registry=https://somewhere\-else\.com/another //registry\.npmjs\.org/:_authToken=MYTOKEN ; would apply to both @myorg and @another ; //somewhere\-else\.com/:_authToken=MYTOKEN ; would apply only to @myorg //somewhere\-else\.com/myorg/:_authToken=MYTOKEN1 ; would apply only to @another //somewhere\-else\.com/another/:_authToken=MYTOKEN2 .fi .RE .SH See also .RS 1 .IP \(bu 2 npm folders .IP \(bu 2 npm config .IP \(bu 2 config .IP \(bu 2 package\.json .IP \(bu 2 npm .RE