1 ---
2 title: npmrc
3 section: 5
4 description: The npm config files
5 github_repo: npm/cli
6 github_branch: latest
7 github_path: docs/lib/content/configuring-npm/npmrc.md
8 redirect_from:
9 - /cli-documentation/configuring-npm/npmrc
10 - /cli-documentation/files/npmrc
11 - /cli-documentation/v11/configuring-npm/npmrc
12 - /cli-documentation/v11/files/npmrc
13 - /cli/configuring-npm/npmrc
14 - /cli/files/npmrc
15 - /cli/v11/files/npmrc
16 - /configuring-npm/npmrc
17 - /files/npmrc
18 ---
19
20 ### Description
21
22 npm gets its config settings from the command line, environment variables, and `npmrc` files.
23
24 The `npm config` command can be used to update and edit the contents of the user and global npmrc files.
25
26 For a list of available configuration options, see [config](/cli/v11/using-npm/config).
27
28 ### Files
29
30 The four relevant files are:
31
32 - per-project config file (`/path/to/my/project/.npmrc`)
33 - per-user config file (`~/.npmrc`)
34 - global config file (`$PREFIX/etc/npmrc`)
35 - npm builtin config file (`/path/to/npm/npmrc`)
36
37 All npm config files are an ini-formatted list of `key = value` parameters. Environment variables can be replaced using `${VARIABLE_NAME}`. For example:
38
39 ```bash
40 cache = ${HOME}/.npm-packages
41 ```
42
43 Each of these files is loaded, and config options are resolved in priority order. For example, a setting in the userconfig file would override the setting in the globalconfig file.
44
45 Array values are specified by adding "[]" after the key name. For example:
46
47 ```bash
48 key[] = "first value"
49 key[] = "second value"
50 ```
51
52 #### Comments
53
54 Lines 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.
55
56 For example:
57
58 ```bash
59 # last modified: 01 Jan 2016
60 ; Set a new registry for a scoped package
61 @myscope:registry=https://mycustomregistry.example.org
62 ```
63
64 #### Per-project config file
65
66 When working locally in a project, a `.npmrc` file in the root of the project (ie, a sibling of `node_modules` and `package.json`) will set config values specific to this project.
67
68 Note that this only applies to the root of the project that you're running npm in. It has no effect when your module is published. For example, you can't publish a module that forces itself to install globally, or in a different location.
69
70 Additionally, this file is not read in global mode, such as when running `npm install -g`.
71
72 #### Per-user config file
73
74 `$HOME/.npmrc` (or the `userconfig` param, if set in the environment or on the command line)
75
76 #### Global config file
77
78 `$PREFIX/etc/npmrc` (or the `globalconfig` param, if set above): This file is an ini-file formatted list of `key = value` parameters. Environment variables can be replaced as above.
79
80 #### Built-in config file
81
82 `path/to/npm/itself/npmrc`
83
84 This is an unchangeable "builtin" configuration file that npm keeps consistent across updates. Set fields in here using the `./configure` script that comes with npm. This is primarily for distribution maintainers to override default configs in a standard and consistent manner.
85
86 ### Auth related configuration
87
88 The settings `_auth`, `_authToken`, `username` and `_password` must all be scoped to a specific registry. This ensures that `npm` will never send credentials to the wrong host.
89
90 The full list is:
91
92 - `_auth` (base64 authentication string)
93 - `_authToken` (authentication token)
94 - `username`
95 - `_password`
96 - `email`
97 - `cafile` (path to certificate authority file)
98 - `keyfile` (path to key file)
99
100 In order to scope these values, they must be prefixed by a URI fragment. If the credential is meant for any request to a registry on a single host, the scope may look like `//registry.npmjs.org/:`. If it must be scoped to a specific path on the host that path may also be provided, such as `//my-custom-registry.org/unique/path:`.
101
102 ```
103 ; bad config
104 _authToken=MYTOKEN
105
106 ; good config
107 @myorg:registry=https://somewhere-else.com/myorg
108 @another:registry=https://somewhere-else.com/another
109 //registry.npmjs.org/:_authToken=MYTOKEN
110
111 ; would apply to both @myorg and @another
112 //somewhere-else.com/:_authToken=MYTOKEN
113
114 ; would apply only to @myorg
115 //somewhere-else.com/myorg/:_authToken=MYTOKEN1
116
117 ; would apply only to @another
118 //somewhere-else.com/another/:_authToken=MYTOKEN2
119 ```
120
121 ### See also
122
123 - [npm folders](/cli/v11/configuring-npm/folders)
124 - [npm config](/cli/v11/commands/npm-config)
125 - [config](/cli/v11/using-npm/config)
126 - [package.json](/cli/v11/configuring-npm/package-json)
127 - [npm](/cli/v11/commands/npm)