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