1<!DOCTYPE html><html><head>
2<meta charset="utf-8">
3<title>npmrc</title>
4<style>
5body {
6    background-color: #ffffff;
7    color: #24292e;
8
9    margin: 0;
10
11    line-height: 1.5;
12
13    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
14}
15#rainbar {
16    height: 10px;
17    background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
18}
19
20a {
21    text-decoration: none;
22    color: #0366d6;
23}
24a:hover {
25    text-decoration: underline;
26}
27
28pre {
29    margin: 1em 0px;
30    padding: 1em;
31    border: solid 1px #e1e4e8;
32    border-radius: 6px;
33
34    display: block;
35    overflow: auto;
36
37    white-space: pre;
38
39    background-color: #f6f8fa;
40    color: #393a34;
41}
42code {
43    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
44    font-size: 85%;
45    padding: 0.2em 0.4em;
46    background-color: #f6f8fa;
47    color: #393a34;
48}
49pre > code {
50    padding: 0;
51    background-color: inherit;
52    color: inherit;
53}
54h1, h2, h3 {
55    font-weight: 600;
56}
57
58#logobar {
59    background-color: #333333;
60    margin: 0 auto;
61    padding: 1em 4em;
62}
63#logobar .logo {
64    float: left;
65}
66#logobar .title {
67    font-weight: 600;
68    color: #dddddd;
69    float: left;
70    margin: 5px 0 0 1em;
71}
72#logobar:after {
73    content: "";
74    display: block;
75    clear: both;
76}
77
78#content {
79    margin: 0 auto;
80    padding: 0 4em;
81}
82
83#table_of_contents > h2 {
84    font-size: 1.17em;
85}
86#table_of_contents ul:first-child {
87    border: solid 1px #e1e4e8;
88    border-radius: 6px;
89    padding: 1em;
90    background-color: #f6f8fa;
91    color: #393a34;
92}
93#table_of_contents ul {
94    list-style-type: none;
95    padding-left: 1.5em;
96}
97#table_of_contents li {
98    font-size: 0.9em;
99}
100#table_of_contents li a {
101    color: #000000;
102}
103
104header.title {
105    border-bottom: solid 1px #e1e4e8;
106}
107header.title > h1 {
108    margin-bottom: 0.25em;
109}
110header.title > .description {
111    display: block;
112    margin-bottom: 0.5em;
113    line-height: 1;
114}
115
116footer#edit {
117    border-top: solid 1px #e1e4e8;
118    margin: 3em 0 4em 0;
119    padding-top: 2em;
120}
121</style>
122</head>
123<body>
124<div id="banner">
125<div id="rainbar"></div>
126<div id="logobar">
127<svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
128<polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
129<polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
130</svg>
131<div class="title">
132npm command-line interface
133</div>
134</div>
135</div>
136
137<section id="content">
138<header class="title">
139<h1 id="npmrc">npmrc</h1>
140<span class="description">The npm config files</span>
141</header>
142
143<section id="table_of_contents">
144<h2 id="table-of-contents">Table of contents</h2>
145<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><li><a href="#files">Files</a></li><ul><li><a href="#comments">Comments</a></li><li><a href="#per-project-config-file">Per-project config file</a></li><li><a href="#per-user-config-file">Per-user config file</a></li><li><a href="#global-config-file">Global config file</a></li><li><a href="#built-in-config-file">Built-in config file</a></li></ul><li><a href="#auth-related-configuration">Auth related configuration</a></li><li><a href="#see-also">See also</a></li></ul></div>
146</section>
147
148<div id="_content"><h3 id="description">Description</h3>
149<p>npm gets its config settings from the command line, environment variables,
150and <code>npmrc</code> files.</p>
151<p>The <code>npm config</code> command can be used to update and edit the contents of the
152user and global npmrc files.</p>
153<p>For a list of available configuration options, see
154<a href="../using-npm/config.html">config</a>.</p>
155<h3 id="files">Files</h3>
156<p>The four relevant files are:</p>
157<ul>
158<li>per-project config file (<code>/path/to/my/project/.npmrc</code>)</li>
159<li>per-user config file (<code>~/.npmrc</code>)</li>
160<li>global config file (<code>$PREFIX/etc/npmrc</code>)</li>
161<li>npm builtin config file (<code>/path/to/npm/npmrc</code>)</li>
162</ul>
163<p>All npm config files are an ini-formatted list of <code>key = value</code> parameters.
164Environment variables can be replaced using <code>${VARIABLE_NAME}</code>. For
165example:</p>
166<pre><code class="language-bash">prefix = ${HOME}/.npm-packages
167</code></pre>
168<p>Each of these files is loaded, and config options are resolved in priority
169order.  For example, a setting in the userconfig file would override the
170setting in the globalconfig file.</p>
171<p>Array values are specified by adding "[]" after the key name. For example:</p>
172<pre><code class="language-bash">key[] = "first value"
173key[] = "second value"
174</code></pre>
175<h4 id="comments">Comments</h4>
176<p>Lines in <code>.npmrc</code> files are interpreted as comments when they begin with a
177<code>;</code> or <code>#</code> character. <code>.npmrc</code> files are parsed by
178<a href="https://github.com/npm/ini">npm/ini</a>, which specifies this comment syntax.</p>
179<p>For example:</p>
180<pre><code class="language-bash"># last modified: 01 Jan 2016
181; Set a new registry for a scoped package
182@myscope:registry=https://mycustomregistry.example.org
183</code></pre>
184<h4 id="per-project-config-file">Per-project config file</h4>
185<p>When working locally in a project, a <code>.npmrc</code> file in the root of the
186project (ie, a sibling of <code>node_modules</code> and <code>package.json</code>) will set
187config values specific to this project.</p>
188<p>Note that this only applies to the root of the project that you're running
189npm in.  It has no effect when your module is published.  For example, you
190can't publish a module that forces itself to install globally, or in a
191different location.</p>
192<p>Additionally, this file is not read in global mode, such as when running
193<code>npm install -g</code>.</p>
194<h4 id="per-user-config-file">Per-user config file</h4>
195<p><code>$HOME/.npmrc</code> (or the <code>userconfig</code> param, if set in the environment or on
196the command line)</p>
197<h4 id="global-config-file">Global config file</h4>
198<p><code>$PREFIX/etc/npmrc</code> (or the <code>globalconfig</code> param, if set above): This file
199is an ini-file formatted list of <code>key = value</code> parameters.  Environment
200variables can be replaced as above.</p>
201<h4 id="built-in-config-file">Built-in config file</h4>
202<p><code>path/to/npm/itself/npmrc</code></p>
203<p>This is an unchangeable "builtin" configuration file that npm keeps
204consistent across updates.  Set fields in here using the <code>./configure</code>
205script that comes with npm.  This is primarily for distribution maintainers
206to override default configs in a standard and consistent manner.</p>
207<h3 id="auth-related-configuration">Auth related configuration</h3>
208<p>The settings <code>_auth</code>, <code>_authToken</code>, <code>username</code> and <code>_password</code> must all be
209scoped to a specific registry. This ensures that <code>npm</code> will never send
210credentials to the wrong host.</p>
211<p>The full list is:</p>
212<ul>
213<li><code>_auth</code> (base64 authentication string)</li>
214<li><code>_authToken</code> (authentication token)</li>
215<li><code>username</code></li>
216<li><code>_password</code></li>
217<li><code>email</code></li>
218<li><code>certfile</code> (path to certificate file)</li>
219<li><code>keyfile</code> (path to key file)</li>
220</ul>
221<p>In order to scope these values, they must be prefixed by a URI fragment.
222If the credential is meant for any request to a registry on a single host,
223the scope may look like <code>//registry.npmjs.org/:</code>. If it must be scoped to a
224specific path on the host that path may also be provided, such as
225<code>//my-custom-registry.org/unique/path:</code>.</p>
226<pre><code>; bad config
227_authToken=MYTOKEN
228
229; good config
230@myorg:registry=https://somewhere-else.com/myorg
231@another:registry=https://somewhere-else.com/another
232//registry.npmjs.org/:_authToken=MYTOKEN
233; would apply to both @myorg and @another
234; //somewhere-else.com/:_authToken=MYTOKEN
235; would apply only to @myorg
236//somewhere-else.com/myorg/:_authToken=MYTOKEN1
237; would apply only to @another
238//somewhere-else.com/another/:_authToken=MYTOKEN2
239</code></pre>
240<h3 id="see-also">See also</h3>
241<ul>
242<li><a href="../configuring-npm/folders.html">npm folders</a></li>
243<li><a href="../commands/npm-config.html">npm config</a></li>
244<li><a href="../using-npm/config.html">config</a></li>
245<li><a href="../configuring-npm/package-json.html">package.json</a></li>
246<li><a href="../commands/npm.html">npm</a></li>
247</ul></div>
248
249<footer id="edit">
250<a href="https://github.com/npm/cli/edit/latest/docs/content/configuring-npm/npmrc.md">
251<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
252<path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path>
253</svg>
254Edit this page on GitHub
255</a>
256</footer>
257</section>
258
259
260
261</body></html>