1NPMRC(5)                                                              NPMRC(5)
2
3
4

NAME

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}. For
31       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 exam‐
63       ple, you can't publish a module that forces itself to install globally,
64       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       The full list is:
93
94_auth (base64 authentication string)
95
96_authToken (authentication token)
97
98username
99
100_password
101
102email
103
104certfile (path to certificate file)
105
106keyfile (path to key file)
107
108
109       In  order  to  scope these values, they must be prefixed by a URI frag‐
110       ment. If the credential is meant for any request to  a  registry  on  a
111       single host, the scope may look like //registry.npmjs.org/:. If it must
112       be scoped to a specific path on the host that path  may  also  be  pro‐
113       vided, such as //my-custom-registry.org/unique/path:.
114
115         ; bad config
116         _authToken=MYTOKEN
117
118         ; good config
119         @myorg:registry=https://somewhere-else.com/myorg
120         @another:registry=https://somewhere-else.com/another
121         //registry.npmjs.org/:_authToken=MYTOKEN
122         ; would apply to both @myorg and @another
123         ; //somewhere-else.com/:_authToken=MYTOKEN
124         ; would apply only to @myorg
125         //somewhere-else.com/myorg/:_authToken=MYTOKEN1
126         ; would apply only to @another
127         //somewhere-else.com/another/:_authToken=MYTOKEN2
128
129   See also
130       •   npm help folders
131
132       •   npm help config
133
134       •   npm help config
135
136package.json ⟨/configuring-npm/package-json⟩
137
138       •   npm help npm
139
140
141
142                                 November 2023                        NPMRC(5)
Impressum