1 ---
2 title: npmrc
3 section: 5
4 description: The npm config files
5 github_repo: npm/cli
6 github_branch: release/v8
7 github_path: docs/lib/content/configuring-npm/npmrc.md
8 redirect_from:
9 - /cli-documentation/v8/configuring-npm/npmrc
10 - /cli-documentation/v8/files/npmrc
11 - /cli/v8/files/npmrc
12 ---
13
14 ### Description
15
16 npm gets its config settings from the command line, environment variables, and `npmrc` files.
17
18 The `npm config` command can be used to update and edit the contents of the user and global npmrc files.
19
20 For a list of available configuration options, see [config](/cli/v8/using-npm/config).
21
22 ### Files
23
24 The four relevant files are:
25
26 - per-project config file (/path/to/my/project/.npmrc)
27 - per-user config file (~/.npmrc)
28 - global config file ($PREFIX/etc/npmrc)
29 - npm builtin config file (/path/to/npm/npmrc)
30
31 All npm config files are an ini-formatted list of `key = value` parameters. Environment variables can be replaced using `${VARIABLE_NAME}`. For example:
32
33 ```bash
34 prefix = ${HOME}/.npm-packages
35 ```
36
37 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.
38
39 Array values are specified by adding "[]" after the key name. For example:
40
41 ```bash
42 key[] = "first value"
43 key[] = "second value"
44 ```
45
46 #### Comments
47
48 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.
49
50 For example:
51
52 ```bash
53 # last modified: 01 Jan 2016
54 ; Set a new registry for a scoped package
55 @myscope:registry=https://mycustomregistry.example.org
56 ```
57
58 #### Per-project config file
59
60 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.
61
62 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.
63
64 Additionally, this file is not read in global mode, such as when running `npm install -g`.
65
66 #### Per-user config file
67
68 `$HOME/.npmrc` (or the `userconfig` param, if set in the environment or on the command line)
69
70 #### Global config file
71
72 `$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.
73
74 #### Built-in config file
75
76 `path/to/npm/itself/npmrc`
77
78 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.
79
80 ### Auth related configuration
81
82 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.
83
84 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:`.
85
86 ```
87 ; bad config
88 _authToken=MYTOKEN
89
90 ; good config
91 @myorg:registry=https://somewhere-else.com/myorg
92 @another:registry=https://somewhere-else.com/another
93 //registry.npmjs.org/:_authToken=MYTOKEN
94 ; would apply to both @myorg and @another
95 ; //somewhere-else.com/:_authToken=MYTOKEN
96 ; would apply only to @myorg
97 //somewhere-else.com/myorg/:_authToken=MYTOKEN1
98 ; would apply only to @another
99 //somewhere-else.com/another/:_authToken=MYTOKEN2
100 ```
101
102 ### See also
103
104 - [npm folders](/cli/v8/configuring-npm/folders)
105 - [npm config](/cli/v8/commands/npm-config)
106 - [config](/cli/v8/using-npm/config)
107 - [package.json](/cli/v8/configuring-npm/package-json)
108 - [npm](/cli/v8/commands/npm)