package-spec.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <!DOCTYPE html><html><head>
  2. <meta charset="utf-8">
  3. <title>Package spec</title>
  4. <style>
  5. body {
  6. background-color: #ffffff;
  7. color: #24292e;
  8. margin: 0;
  9. line-height: 1.5;
  10. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  11. }
  12. #rainbar {
  13. height: 10px;
  14. background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
  15. }
  16. a {
  17. text-decoration: none;
  18. color: #0366d6;
  19. }
  20. a:hover {
  21. text-decoration: underline;
  22. }
  23. pre {
  24. margin: 1em 0px;
  25. padding: 1em;
  26. border: solid 1px #e1e4e8;
  27. border-radius: 6px;
  28. display: block;
  29. overflow: auto;
  30. white-space: pre;
  31. background-color: #f6f8fa;
  32. color: #393a34;
  33. }
  34. code {
  35. font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
  36. font-size: 85%;
  37. padding: 0.2em 0.4em;
  38. background-color: #f6f8fa;
  39. color: #393a34;
  40. }
  41. pre > code {
  42. padding: 0;
  43. background-color: inherit;
  44. color: inherit;
  45. }
  46. h1, h2, h3 {
  47. font-weight: 600;
  48. }
  49. #logobar {
  50. background-color: #333333;
  51. margin: 0 auto;
  52. padding: 1em 4em;
  53. }
  54. #logobar .logo {
  55. float: left;
  56. }
  57. #logobar .title {
  58. font-weight: 600;
  59. color: #dddddd;
  60. float: left;
  61. margin: 5px 0 0 1em;
  62. }
  63. #logobar:after {
  64. content: "";
  65. display: block;
  66. clear: both;
  67. }
  68. #content {
  69. margin: 0 auto;
  70. padding: 0 4em;
  71. }
  72. #table_of_contents > h2 {
  73. font-size: 1.17em;
  74. }
  75. #table_of_contents ul:first-child {
  76. border: solid 1px #e1e4e8;
  77. border-radius: 6px;
  78. padding: 1em;
  79. background-color: #f6f8fa;
  80. color: #393a34;
  81. }
  82. #table_of_contents ul {
  83. list-style-type: none;
  84. padding-left: 1.5em;
  85. }
  86. #table_of_contents li {
  87. font-size: 0.9em;
  88. }
  89. #table_of_contents li a {
  90. color: #000000;
  91. }
  92. header.title {
  93. border-bottom: solid 1px #e1e4e8;
  94. }
  95. header.title > h1 {
  96. margin-bottom: 0.25em;
  97. }
  98. header.title > .description {
  99. display: block;
  100. margin-bottom: 0.5em;
  101. line-height: 1;
  102. }
  103. header.title .version {
  104. font-size: 0.8em;
  105. color: #666666;
  106. }
  107. footer#edit {
  108. border-top: solid 1px #e1e4e8;
  109. margin: 3em 0 4em 0;
  110. padding-top: 2em;
  111. }
  112. table {
  113. width: 100%;
  114. margin: 1em 0;
  115. border-radius: 6px;
  116. border: 1px solid #e1e4e8;
  117. overflow: hidden;
  118. border-collapse: separate;
  119. border-spacing: 0;
  120. }
  121. table thead {
  122. background-color: #f6f8fa;
  123. }
  124. table tbody {
  125. background-color: #ffffff;
  126. }
  127. table th,
  128. table td {
  129. padding: 0.75em;
  130. text-align: left;
  131. border-right: 1px solid #e1e4e8;
  132. border-bottom: 1px solid #e1e4e8;
  133. }
  134. table th:last-child,
  135. table td:last-child {
  136. border-right: none;
  137. }
  138. table tbody tr:last-child td {
  139. border-bottom: none;
  140. }
  141. table th {
  142. font-weight: 600;
  143. background-color: #f6f8fa;
  144. }
  145. table code {
  146. white-space: nowrap;
  147. }
  148. </style>
  149. </head>
  150. <body>
  151. <div id="banner">
  152. <div id="rainbar"></div>
  153. <div id="logobar">
  154. <svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
  155. <polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
  156. <polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
  157. </svg>
  158. <div class="title">
  159. npm command-line interface
  160. </div>
  161. </div>
  162. </div>
  163. <section id="content">
  164. <header class="title">
  165. <h1 id="----package-spec----11120">
  166. <span>Package spec</span>
  167. <span class="version">@11.12.0</span>
  168. </h1>
  169. <span class="description">Package name specifier</span>
  170. </header>
  171. <section id="table_of_contents">
  172. <h2 id="table-of-contents">Table of contents</h2>
  173. <div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><li><a href="#package-name">Package name</a></li><li><a href="#aliases">Aliases</a></li><li><a href="#folders">Folders</a></li><li><a href="#tarballs">Tarballs</a></li><li><a href="#git-urls">git urls</a></li><li><a href="#see-also">See also</a></li></ul></div>
  174. </section>
  175. <div id="_content"><h3 id="description">Description</h3>
  176. <p>Commands like <code>npm install</code> and the dependency sections in the <code>package.json</code> use a package name specifier.
  177. This can be many different things that all refer to a "package". Examples include a package name, git url, tarball, or local directory.
  178. These will generally be referred to as <code>&lt;package-spec&gt;</code> in the help output for the npm commands that use this package name specifier.</p>
  179. <h3 id="package-name">Package name</h3>
  180. <ul>
  181. <li><code>[&lt;@scope&gt;/]&lt;pkg&gt;</code></li>
  182. <li><code>[&lt;@scope&gt;/]&lt;pkg&gt;@&lt;tag&gt;</code></li>
  183. <li><code>[&lt;@scope&gt;/]&lt;pkg&gt;@&lt;version&gt;</code></li>
  184. <li><code>[&lt;@scope&gt;/]&lt;pkg&gt;@&lt;version range&gt;</code></li>
  185. </ul>
  186. <p>Refers to a package by name, with or without a scope, and optionally tag, version, or version range.
  187. This is typically used in combination with the <a href="../using-npm/config#registry.html">registry</a> config to refer to a package in a registry.</p>
  188. <p>Examples:</p>
  189. <ul>
  190. <li><code>npm</code></li>
  191. <li><code>@npmcli/arborist</code></li>
  192. <li><code>@npmcli/arborist@latest</code></li>
  193. <li><code>npm@6.13.1</code></li>
  194. <li><code>npm@^4.0.0</code></li>
  195. </ul>
  196. <h3 id="aliases">Aliases</h3>
  197. <ul>
  198. <li><code>&lt;alias&gt;@npm:&lt;name&gt;</code></li>
  199. </ul>
  200. <p>Primarily used by commands like <code>npm install</code> and in the dependency sections in the <code>package.json</code>, this refers to a package by an alias.
  201. The <code>&lt;alias&gt;</code> is the name of the package as it is reified in the <code>node_modules</code> folder, and the <code>&lt;name&gt;</code> refers to a package name as found in the configured registry.</p>
  202. <p>See <code>Package name</code> above for more info on referring to a package by name, and <a href="../using-npm/config#registry.html">registry</a> for configuring which registry is used when referring to a package by name.</p>
  203. <p>Examples:</p>
  204. <ul>
  205. <li><code>semver@npm:@npmcli/semver-with-patch</code></li>
  206. <li><code>semver@npm:semver@7.2.2</code></li>
  207. <li><code>semver@npm:semver@legacy</code></li>
  208. </ul>
  209. <h3 id="folders">Folders</h3>
  210. <ul>
  211. <li><code>&lt;folder&gt;</code></li>
  212. </ul>
  213. <p>This refers to a package on the local filesystem.
  214. Specifically this is a folder with a <code>package.json</code> file in it.
  215. This <em>should</em> always be prefixed with a <code>/</code> or <code>./</code> (or your OS equivalent) to reduce confusion.
  216. npm currently will parse a string with more than one <code>/</code> in it as a folder, but this is legacy behavior that may be removed in a future version.</p>
  217. <p>Examples:</p>
  218. <ul>
  219. <li><code>./my-package</code></li>
  220. <li><code>/opt/npm/my-package</code></li>
  221. </ul>
  222. <h3 id="tarballs">Tarballs</h3>
  223. <ul>
  224. <li><code>&lt;tarball file&gt;</code></li>
  225. <li><code>&lt;tarball url&gt;</code></li>
  226. </ul>
  227. <p>Examples:</p>
  228. <ul>
  229. <li><code>./my-package.tgz</code></li>
  230. <li><code>https://registry.npmjs.org/semver/-/semver-1.0.0.tgz</code></li>
  231. </ul>
  232. <p>Refers to a package in a tarball format, either on the local filesystem or remotely via url.
  233. This is the format that packages exist in when uploaded to a registry.</p>
  234. <h3 id="git-urls">git urls</h3>
  235. <ul>
  236. <li><code>&lt;git:// url&gt;</code></li>
  237. <li><code>&lt;github username&gt;/&lt;github project&gt;</code></li>
  238. </ul>
  239. <p>Refers to a package in a git repo.
  240. This can be a full git url, git shorthand, or a username/package on GitHub.
  241. You can specify a git tag, branch, or other git ref by appending <code>#ref</code>.</p>
  242. <p>Examples:</p>
  243. <ul>
  244. <li><code>https://github.com/npm/cli.git</code></li>
  245. <li><code>git@github.com:npm/cli.git</code></li>
  246. <li><code>git+ssh://git@github.com/npm/cli#v6.0.0</code></li>
  247. <li><code>github:npm/cli#HEAD</code></li>
  248. <li><code>npm/cli#c12ea07</code></li>
  249. </ul>
  250. <h3 id="see-also">See also</h3>
  251. <ul>
  252. <li><a href="https://npm.im/npm-package-arg">npm-package-arg</a></li>
  253. <li><a href="../using-npm/scope.html">scope</a></li>
  254. <li><a href="../using-npm/config.html">config</a></li>
  255. </ul></div>
  256. <footer id="edit">
  257. <a href="https://github.com/npm/cli/edit/latest/docs/lib/content/using-npm/package-spec.md">
  258. <svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
  259. <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>
  260. </svg>
  261. Edit this page on GitHub
  262. </a>
  263. </footer>
  264. </section>
  265. </body></html>