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