npm.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <html><head>
  2. <title>npm</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="npm">npm</h1>
  125. <span class="description">javascript package manager</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="#synopsis">Synopsis</a></li><li><a href="#version">Version</a></li><li><a href="#description">Description</a></li><li><a href="#important">Important</a></li><li><a href="#introduction">Introduction</a></li><li><a href="#dependencies">Dependencies</a></li><li><a href="#directories">Directories</a></li><li><a href="#developer-usage">Developer Usage</a></li><ul><li><a href="#configuration">Configuration</a></li></ul><li><a href="#contributions">Contributions</a></li><li><a href="#bugs">Bugs</a></li><li><a href="#feature-requests">Feature Requests</a></li><li><a href="#see-also">See Also</a></li></ul></div>
  130. </section>
  131. <div id="_content"><h3 id="synopsis">Synopsis</h3>
  132. <pre lang="bash"><code>npm &lt;command&gt; [args]
  133. </code></pre>
  134. <h3 id="version">Version</h3>
  135. <p>8.1.2</p>
  136. <h3 id="description">Description</h3>
  137. <p>npm is the package manager for the Node JavaScript platform. It puts
  138. modules in place so that node can find them, and manages dependency
  139. conflicts intelligently.</p>
  140. <p>It is extremely configurable to support a variety of use cases. Most
  141. commonly, you use it to publish, discover, install, and develop node
  142. programs.</p>
  143. <p>Run <code>npm help</code> to get a list of available commands.</p>
  144. <h3 id="important">Important</h3>
  145. <p>npm comes preconfigured to use npm’s public registry at
  146. <a href="https://registry.npmjs.org">https://registry.npmjs.org</a> by default. Use of the npm public registry is
  147. subject to terms of use available at
  148. <a href="https://docs.npmjs.com/policies/terms">https://docs.npmjs.com/policies/terms</a>.</p>
  149. <p>You can configure npm to use any compatible registry you like, and even
  150. run your own registry. Use of someone else’s registry is governed by
  151. their terms of use.</p>
  152. <h3 id="introduction">Introduction</h3>
  153. <p>You probably got npm because you want to install stuff.</p>
  154. <p>The very first thing you will most likely want to run in any node
  155. program is <code>npm install</code> to install its dependencies.</p>
  156. <p>You can also run <code>npm install blerg</code> to install the latest version of
  157. “blerg”. Check out <a href="../commands/npm-install.html"><code>npm install</code></a> for more
  158. info. It can do a lot of stuff.</p>
  159. <p>Use the <code>npm search</code> command to show everything that’s available in the
  160. public registry. Use <code>npm ls</code> to show everything you’ve installed.</p>
  161. <h3 id="dependencies">Dependencies</h3>
  162. <p>If a package lists a dependency using a git URL, npm will install that
  163. dependency using the <a href="https://github.com/git-guides/install-git"><code>git</code></a>
  164. command and will generate an error if it is not installed.</p>
  165. <p>If one of the packages npm tries to install is a native node module and
  166. requires compiling of C++ Code, npm will use
  167. <a href="https://github.com/nodejs/node-gyp">node-gyp</a> for that task.
  168. For a Unix system, <a href="https://github.com/nodejs/node-gyp">node-gyp</a>
  169. needs Python, make and a buildchain like GCC. On Windows,
  170. Python and Microsoft Visual Studio C++ are needed. For more information
  171. visit <a href="https://github.com/nodejs/node-gyp">the node-gyp repository</a> and
  172. the <a href="https://github.com/nodejs/node-gyp/wiki">node-gyp Wiki</a>.</p>
  173. <h3 id="directories">Directories</h3>
  174. <p>See <a href="../configuring-npm/folders.html"><code>folders</code></a> to learn about where npm puts
  175. stuff.</p>
  176. <p>In particular, npm has two modes of operation:</p>
  177. <ul>
  178. <li>local mode:
  179. npm installs packages into the current project directory, which
  180. defaults to the current working directory. Packages install to
  181. <code>./node_modules</code>, and bins to <code>./node_modules/.bin</code>.</li>
  182. <li>global mode:
  183. npm installs packages into the install prefix at
  184. <code>$npm_config_prefix/lib/node_modules</code> and bins to
  185. <code>$npm_config_prefix/bin</code>.</li>
  186. </ul>
  187. <p>Local mode is the default. Use <code>-g</code> or <code>--global</code> on any command to
  188. run in global mode instead.</p>
  189. <h3 id="developer-usage">Developer Usage</h3>
  190. <p>If you’re using npm to develop and publish your code, check out the
  191. following help topics:</p>
  192. <ul>
  193. <li>json:
  194. Make a package.json file. See
  195. <a href="../configuring-npm/package-json.html"><code>package.json</code></a>.</li>
  196. <li>link:
  197. Links your current working code into Node’s path, so that you don’t
  198. have to reinstall every time you make a change. Use <a href="../commands/npm-link.html"><code>npm link</code></a> to do this.</li>
  199. <li>install:
  200. It’s a good idea to install things if you don’t need the symbolic
  201. link. Especially, installing other peoples code from the registry is
  202. done via <a href="../commands/npm-install.html"><code>npm install</code></a></li>
  203. <li>adduser:
  204. Create an account or log in. When you do this, npm will store
  205. credentials in the user config file config file.</li>
  206. <li>publish:
  207. Use the <a href="../commands/npm-publish.html"><code>npm publish</code></a> command to upload your
  208. code to the registry.</li>
  209. </ul>
  210. <h4 id="configuration">Configuration</h4>
  211. <p>npm is extremely configurable. It reads its configuration options from
  212. 5 places.</p>
  213. <ul>
  214. <li>Command line switches:
  215. Set a config with <code>--key val</code>. All keys take a value, even if they
  216. are booleans (the config parser doesn’t know what the options are at
  217. the time of parsing). If you do not provide a value (<code>--key</code>) then
  218. the option is set to boolean <code>true</code>.</li>
  219. <li>Environment Variables:
  220. Set any config by prefixing the name in an environment variable with
  221. <code>npm_config_</code>. For example, <code>export npm_config_key=val</code>.</li>
  222. <li>User Configs:
  223. The file at <code>$HOME/.npmrc</code> is an ini-formatted list of configs. If
  224. present, it is parsed. If the <code>userconfig</code> option is set in the cli
  225. or env, that file will be used instead.</li>
  226. <li>Global Configs:
  227. The file found at <code>./etc/npmrc</code> (relative to the global prefix will be
  228. parsed if it is found. See <a href="../commands/npm-prefix.html"><code>npm prefix</code></a> for
  229. more info on the global prefix. If the <code>globalconfig</code> option is set
  230. in the cli, env, or user config, then that file is parsed instead.</li>
  231. <li>Defaults:
  232. npm’s default configuration options are defined in
  233. lib/utils/config-defs.js. These must not be changed.</li>
  234. </ul>
  235. <p>See <a href="../using-npm/config.html"><code>config</code></a> for much much more information.</p>
  236. <h3 id="contributions">Contributions</h3>
  237. <p>Patches welcome!</p>
  238. <p>If you would like to help, but don’t know what to work on, read the
  239. <a href="https://github.com/npm/cli/blob/latest/CONTRIBUTING.md">contributing
  240. guidelines</a> and
  241. check the issues list.</p>
  242. <h3 id="bugs">Bugs</h3>
  243. <p>When you find issues, please report them:
  244. <a href="https://github.com/npm/cli/issues">https://github.com/npm/cli/issues</a></p>
  245. <p>Please be sure to follow the template and bug reporting guidelines.</p>
  246. <h3 id="feature-requests">Feature Requests</h3>
  247. <p>Discuss new feature ideas on our discussion forum:</p>
  248. <ul>
  249. <li><a href="https://github.com/npm/feedback">https://github.com/npm/feedback</a></li>
  250. </ul>
  251. <p>Or suggest formal RFC proposals:</p>
  252. <ul>
  253. <li><a href="https://github.com/npm/rfcs">https://github.com/npm/rfcs</a></li>
  254. </ul>
  255. <h3 id="see-also">See Also</h3>
  256. <ul>
  257. <li><a href="../commands/npm-help.html">npm help</a></li>
  258. <li><a href="../configuring-npm/package-json.html">package.json</a></li>
  259. <li><a href="../configuring-npm/npmrc.html">npmrc</a></li>
  260. <li><a href="../commands/npm-config.html">npm config</a></li>
  261. <li><a href="../commands/npm-install.html">npm install</a></li>
  262. <li><a href="../commands/npm-prefix.html">npm prefix</a></li>
  263. <li><a href="../commands/npm-publish.html">npm publish</a></li>
  264. </ul>
  265. </div>
  266. <footer id="edit">
  267. <a href="https://github.com/npm/cli/edit/latest/docs/content/commands/npm.md">
  268. <svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
  269. <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>
  270. </svg>
  271. Edit this page on GitHub
  272. </a>
  273. </footer>
  274. </section>
  275. </body></html>