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 Auth related configuration
88 The settings _auth, _authToken, username and _password must all be
89 scoped to a specific registry. This ensures that npm will never send
90 credentials to the wrong host.
91
92 In order to scope these values, they must be prefixed by a URI frag‐
93 ment. If the credential is meant for any request to a registry on a
94 single host, the scope may look like //registry.npmjs.org/:. If it must
95 be scoped to a specific path on the host that path may also be pro‐
96 vided, such as //my-custom-registry.org/unique/path:.
97
98 ; bad config
99 _authToken=MYTOKEN
100
101 ; good config
102 @myorg:registry=https://somewhere-else.com/myorg
103 @another:registry=https://somewhere-else.com/another
104 //registry.npmjs.org/:_authToken=MYTOKEN
105 ; would apply to both @myorg and @another
106 ; //somewhere-else.com/:_authToken=MYTOKEN
107 ; would apply only to @myorg
108 //somewhere-else.com/myorg/:_authToken=MYTOKEN1
109 ; would apply only to @another
110 //somewhere-else.com/another/:_authToken=MYTOKEN2
111
112 See also
113 • npm help folders
114
115 • npm help config
116
117 • npm help config
118
119 • npm help package.json
120
121 • npm help npm
122
123
124
125
126 September 2022 NPMRC(5)