• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2section: configuring-npm
3title: npmrc
4description: The npm config files
5---
6
7# npmrc(5)
8
9## The npm config files
10
11### Description
12
13npm gets its config settings from the command line, environment
14variables, and `npmrc` files.
15
16The `npm config` command can be used to update and edit the contents
17of the user and global npmrc files.
18
19For a list of available configuration options, see [config](/using-npm/config).
20
21### Files
22
23The four relevant files are:
24
25* per-project config file (/path/to/my/project/.npmrc)
26* per-user config file (~/.npmrc)
27* global config file ($PREFIX/etc/npmrc)
28* npm builtin config file (/path/to/npm/npmrc)
29
30All npm config files are an ini-formatted list of `key = value`
31parameters.  Environment variables can be replaced using
32`${VARIABLE_NAME}`. For example:
33
34```bash
35prefix = ${HOME}/.npm-packages
36```
37
38Each of these files is loaded, and config options are resolved in
39priority order.  For example, a setting in the userconfig file would
40override the setting in the globalconfig file.
41
42Array values are specified by adding "[]" after the key name. For
43example:
44
45```bash
46key[] = "first value"
47key[] = "second value"
48```
49
50#### Comments
51
52Lines in `.npmrc` files are interpreted as comments when they begin with a `;` or `#` character. `.npmrc` files are parsed by [npm/ini](https://github.com/npm/ini), which specifies this comment syntax.
53
54For example:
55
56```bash
57# last modified: 01 Jan 2016
58; Set a new registry for a scoped package
59@myscope:registry=https://mycustomregistry.example.org
60```
61
62#### Per-project config file
63
64When working locally in a project, a `.npmrc` file in the root of the
65project (ie, a sibling of `node_modules` and `package.json`) will set
66config values specific to this project.
67
68Note that this only applies to the root of the project that you're
69running npm in.  It has no effect when your module is published.  For
70example, you can't publish a module that forces itself to install
71globally, or in a different location.
72
73Additionally, this file is not read in global mode, such as when running
74`npm install -g`.
75
76#### Per-user config file
77
78`$HOME/.npmrc` (or the `userconfig` param, if set in the environment
79or on the command line)
80
81#### Global config file
82
83`$PREFIX/etc/npmrc` (or the `globalconfig` param, if set above):
84This file is an ini-file formatted list of `key = value` parameters.
85Environment variables can be replaced as above.
86
87#### Built-in config file
88
89`path/to/npm/itself/npmrc`
90
91This is an unchangeable "builtin" configuration file that npm keeps
92consistent across updates.  Set fields in here using the `./configure`
93script that comes with npm.  This is primarily for distribution
94maintainers to override default configs in a standard and consistent
95manner.
96
97### See also
98
99* [npm folders](/configuring-npm/folders)
100* [npm config](/cli-commands/npm-config)
101* [config](/using-npm/config)
102* [package.json](/configuring-npm/package-json)
103* [npm](/cli-commands/npm)
104