reggi/dev-engines
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: npmrc |
| 3 | section: 5 |
| 4 | description: The npm config files |
| 5 | github_repo: npm/cli |
| 6 | github_branch: release/v6 |
| 7 | github_path: docs/content/configuring-npm/npmrc.md |
| 8 | redirect_from: |
| 9 | - /cli-documentation/v6/configuring-npm/npmrc |
| 10 | - /cli-documentation/v6/files/npmrc |
| 11 | - /cli/v6/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/v6/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 | ### See also |
| 81 | |
| 82 | - [npm folders](/cli/v6/configuring-npm/folders) |
| 83 | - [npm config](/cli/v6/commands/npm-config) |
| 84 | - [config](/cli/v6/using-npm/config) |
| 85 | - [package.json](/cli/v6/configuring-npm/package-json) |
| 86 | - [npm](/cli/v6/commands/npm) |