npmrc.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <html><head>
  2. <title>npmrc</title>
  3. <style>
  4. body {
  5. background-color: #ffffff;
  6. color: #24292e;
  7. margin: 0;
  8. line-height: 1.5;
  9. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  10. }
  11. #rainbar {
  12. height: 10px;
  13. background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
  14. }
  15. a {
  16. text-decoration: none;
  17. color: #0366d6;
  18. }
  19. a:hover {
  20. text-decoration: underline;
  21. }
  22. pre {
  23. margin: 1em 0px;
  24. padding: 1em;
  25. border: solid 1px #e1e4e8;
  26. border-radius: 6px;
  27. display: block;
  28. overflow: auto;
  29. white-space: pre;
  30. background-color: #f6f8fa;
  31. color: #393a34;
  32. }
  33. code {
  34. font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
  35. font-size: 85%;
  36. padding: 0.2em 0.4em;
  37. background-color: #f6f8fa;
  38. color: #393a34;
  39. }
  40. pre > code {
  41. padding: 0;
  42. background-color: inherit;
  43. color: inherit;
  44. }
  45. h1, h2, h3 {
  46. font-weight: 600;
  47. }
  48. #logobar {
  49. background-color: #333333;
  50. margin: 0 auto;
  51. padding: 1em 4em;
  52. }
  53. #logobar .logo {
  54. float: left;
  55. }
  56. #logobar .title {
  57. font-weight: 600;
  58. color: #dddddd;
  59. float: left;
  60. margin: 5px 0 0 1em;
  61. }
  62. #logobar:after {
  63. content: "";
  64. display: block;
  65. clear: both;
  66. }
  67. #content {
  68. margin: 0 auto;
  69. padding: 0 4em;
  70. }
  71. #table_of_contents > h2 {
  72. font-size: 1.17em;
  73. }
  74. #table_of_contents ul:first-child {
  75. border: solid 1px #e1e4e8;
  76. border-radius: 6px;
  77. padding: 1em;
  78. background-color: #f6f8fa;
  79. color: #393a34;
  80. }
  81. #table_of_contents ul {
  82. list-style-type: none;
  83. padding-left: 1.5em;
  84. }
  85. #table_of_contents li {
  86. font-size: 0.9em;
  87. }
  88. #table_of_contents li a {
  89. color: #000000;
  90. }
  91. header.title {
  92. border-bottom: solid 1px #e1e4e8;
  93. }
  94. header.title > h1 {
  95. margin-bottom: 0.25em;
  96. }
  97. header.title > .description {
  98. display: block;
  99. margin-bottom: 0.5em;
  100. line-height: 1;
  101. }
  102. footer#edit {
  103. border-top: solid 1px #e1e4e8;
  104. margin: 3em 0 4em 0;
  105. padding-top: 2em;
  106. }
  107. </style>
  108. </head>
  109. <body>
  110. <div id="banner">
  111. <div id="rainbar"></div>
  112. <div id="logobar">
  113. <svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
  114. <polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
  115. <polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
  116. </svg>
  117. <div class="title">
  118. npm command-line interface
  119. </div>
  120. </div>
  121. </div>
  122. <section id="content">
  123. <header class="title">
  124. <h1 id="npmrc">npmrc</h1>
  125. <span class="description">The npm config files</span>
  126. </header>
  127. <section id="table_of_contents">
  128. <h2 id="table-of-contents">Table of contents</h2>
  129. <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="#see-also">See also</a></li></ul></div>
  130. </section>
  131. <div id="_content"><h3 id="description">Description</h3>
  132. <p>npm gets its config settings from the command line, environment variables,
  133. and <code>npmrc</code> files.</p>
  134. <p>The <code>npm config</code> command can be used to update and edit the contents of the
  135. user and global npmrc files.</p>
  136. <p>For a list of available configuration options, see
  137. <a href="../using-npm/config.html">config</a>.</p>
  138. <h3 id="files">Files</h3>
  139. <p>The four relevant files are:</p>
  140. <ul>
  141. <li>per-project config file (/path/to/my/project/.npmrc)</li>
  142. <li>per-user config file (~/.npmrc)</li>
  143. <li>global config file ($PREFIX/etc/npmrc)</li>
  144. <li>npm builtin config file (/path/to/npm/npmrc)</li>
  145. </ul>
  146. <p>All npm config files are an ini-formatted list of <code>key = value</code> parameters.
  147. Environment variables can be replaced using <code>${VARIABLE_NAME}</code>. For
  148. example:</p>
  149. <pre lang="bash"><code>prefix = ${HOME}/.npm-packages
  150. </code></pre>
  151. <p>Each of these files is loaded, and config options are resolved in priority
  152. order. For example, a setting in the userconfig file would override the
  153. setting in the globalconfig file.</p>
  154. <p>Array values are specified by adding “[]” after the key name. For example:</p>
  155. <pre lang="bash"><code>key[] = "first value"
  156. key[] = "second value"
  157. </code></pre>
  158. <h4 id="comments">Comments</h4>
  159. <p>Lines in <code>.npmrc</code> files are interpreted as comments when they begin with a
  160. <code>;</code> or <code>#</code> character. <code>.npmrc</code> files are parsed by
  161. <a href="https://github.com/npm/ini">npm/ini</a>, which specifies this comment syntax.</p>
  162. <p>For example:</p>
  163. <pre lang="bash"><code># last modified: 01 Jan 2016
  164. ; Set a new registry for a scoped package
  165. @myscope:registry=https://mycustomregistry.example.org
  166. </code></pre>
  167. <h4 id="per-project-config-file">Per-project config file</h4>
  168. <p>When working locally in a project, a <code>.npmrc</code> file in the root of the
  169. project (ie, a sibling of <code>node_modules</code> and <code>package.json</code>) will set
  170. config values specific to this project.</p>
  171. <p>Note that this only applies to the root of the project that you’re running
  172. npm in. It has no effect when your module is published. For example, you
  173. can’t publish a module that forces itself to install globally, or in a
  174. different location.</p>
  175. <p>Additionally, this file is not read in global mode, such as when running
  176. <code>npm install -g</code>.</p>
  177. <h4 id="per-user-config-file">Per-user config file</h4>
  178. <p><code>$HOME/.npmrc</code> (or the <code>userconfig</code> param, if set in the environment or on
  179. the command line)</p>
  180. <h4 id="global-config-file">Global config file</h4>
  181. <p><code>$PREFIX/etc/npmrc</code> (or the <code>globalconfig</code> param, if set above): This file
  182. is an ini-file formatted list of <code>key = value</code> parameters. Environment
  183. variables can be replaced as above.</p>
  184. <h4 id="built-in-config-file">Built-in config file</h4>
  185. <p><code>path/to/npm/itself/npmrc</code></p>
  186. <p>This is an unchangeable “builtin” configuration file that npm keeps
  187. consistent across updates. Set fields in here using the <code>./configure</code>
  188. script that comes with npm. This is primarily for distribution maintainers
  189. to override default configs in a standard and consistent manner.</p>
  190. <h3 id="see-also">See also</h3>
  191. <ul>
  192. <li><a href="../configuring-npm/folders.html">npm folders</a></li>
  193. <li><a href="../commands/npm-config.html">npm config</a></li>
  194. <li><a href="../using-npm/config.html">config</a></li>
  195. <li><a href="../configuring-npm/package-json.html">package.json</a></li>
  196. <li><a href="../commands/npm.html">npm</a></li>
  197. </ul>
  198. </div>
  199. <footer id="edit">
  200. <a href="https://github.com/npm/cli/edit/latest/docs/content/configuring-npm/npmrc.md">
  201. <svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
  202. <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>
  203. </svg>
  204. Edit this page on GitHub
  205. </a>
  206. </footer>
  207. </section>
  208. </body></html>