npm-ls.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <!DOCTYPE html><html><head>
  2. <meta charset="utf-8">
  3. <title>npm-ls</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="----npm-ls----11120">
  166. <span>npm-ls</span>
  167. <span class="version">@11.12.0</span>
  168. </h1>
  169. <span class="description">List installed packages</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="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#all"><code>all</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#long"><code>long</code></a></li><li><a href="#parseable"><code>parseable</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#depth"><code>depth</code></a></li><li><a href="#omit"><code>omit</code></a></li><li><a href="#include"><code>include</code></a></li><li><a href="#link"><code>link</code></a></li><li><a href="#package-lock-only"><code>package-lock-only</code></a></li><li><a href="#unicode"><code>unicode</code></a></li><li><a href="#workspace"><code>workspace</code></a></li><li><a href="#workspaces"><code>workspaces</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#install-links"><code>install-links</code></a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
  174. </section>
  175. <div id="_content"><h3 id="synopsis">Synopsis</h3>
  176. <pre><code class="language-bash">npm ls &lt;package-spec&gt;
  177. alias: list
  178. </code></pre>
  179. <h3 id="description">Description</h3>
  180. <p>This command will print to stdout all the versions of packages that are installed, as well as their dependencies when <code>--all</code> is specified, in a tree structure.</p>
  181. <p>Note: to get a "bottoms up" view of why a given package is included in the tree at all, use <a href="../commands/npm-explain.html"><code>npm explain</code></a>.</p>
  182. <p>Positional arguments are <code>name@version-range</code> identifiers, which will limit the results to only the paths to the packages named.
  183. Note that nested packages will <em>also</em> show the paths to the specified packages.
  184. For example, running <code>npm ls promzard</code> in npm's source tree will show:</p>
  185. <pre><code class="language-bash">npm@11.12.0 /path/to/npm
  186. └─┬ init-package-json@0.0.4
  187. └── promzard@0.1.5
  188. </code></pre>
  189. <p>It will print out extraneous, missing, and invalid packages.</p>
  190. <p>If a project specifies git urls for dependencies these are shown in parentheses after the <code>name@version</code> to make it easier for users to recognize potential forks of a project.</p>
  191. <p>The tree shown is the logical dependency tree, based on package dependencies, not the physical layout of your <code>node_modules</code> folder.</p>
  192. <p>When run as <code>ll</code> or <code>la</code>, it shows extended information by default.</p>
  193. <h3 id="configuration">Configuration</h3>
  194. <h4 id="all"><code>all</code></h4>
  195. <ul>
  196. <li>Default: false</li>
  197. <li>Type: Boolean</li>
  198. </ul>
  199. <p>When running <code>npm outdated</code> and <code>npm ls</code>, setting <code>--all</code> will show all
  200. outdated or installed packages, rather than only those directly depended
  201. upon by the current project.</p>
  202. <h4 id="json"><code>json</code></h4>
  203. <ul>
  204. <li>Default: false</li>
  205. <li>Type: Boolean</li>
  206. </ul>
  207. <p>Whether or not to output JSON data, rather than the normal output.</p>
  208. <ul>
  209. <li>In <code>npm pkg set</code> it enables parsing set values with JSON.parse() before
  210. saving them to your <code>package.json</code>.</li>
  211. </ul>
  212. <p>Not supported by all npm commands.</p>
  213. <h4 id="long"><code>long</code></h4>
  214. <ul>
  215. <li>Default: false</li>
  216. <li>Type: Boolean</li>
  217. </ul>
  218. <p>Show extended information in <code>ls</code>, <code>search</code>, and <code>help-search</code>.</p>
  219. <h4 id="parseable"><code>parseable</code></h4>
  220. <ul>
  221. <li>Default: false</li>
  222. <li>Type: Boolean</li>
  223. </ul>
  224. <p>Output parseable results from commands that write to standard output. For
  225. <code>npm search</code>, this will be tab-separated table format.</p>
  226. <h4 id="global"><code>global</code></h4>
  227. <ul>
  228. <li>Default: false</li>
  229. <li>Type: Boolean</li>
  230. </ul>
  231. <p>Operates in "global" mode, so that packages are installed into the <code>prefix</code>
  232. folder instead of the current working directory. See
  233. <a href="../configuring-npm/folders.html">folders</a> for more on the differences in behavior.</p>
  234. <ul>
  235. <li>packages are installed into the <code>{prefix}/lib/node_modules</code> folder, instead
  236. of the current working directory.</li>
  237. <li>bin files are linked to <code>{prefix}/bin</code></li>
  238. <li>man pages are linked to <code>{prefix}/share/man</code></li>
  239. </ul>
  240. <h4 id="depth"><code>depth</code></h4>
  241. <ul>
  242. <li>Default: <code>Infinity</code> if <code>--all</code> is set; otherwise, <code>0</code></li>
  243. <li>Type: null or Number</li>
  244. </ul>
  245. <p>The depth to go when recursing packages for <code>npm ls</code>.</p>
  246. <p>If not set, <code>npm ls</code> will show only the immediate dependencies of the root
  247. project. If <code>--all</code> is set, then npm will show all dependencies by default.</p>
  248. <h4 id="omit"><code>omit</code></h4>
  249. <ul>
  250. <li>Default: 'dev' if the <code>NODE_ENV</code> environment variable is set to
  251. 'production'; otherwise, empty.</li>
  252. <li>Type: "dev", "optional", or "peer" (can be set multiple times)</li>
  253. </ul>
  254. <p>Dependency types to omit from the installation tree on disk.</p>
  255. <p>Note that these dependencies <em>are</em> still resolved and added to the
  256. <code>package-lock.json</code> or <code>npm-shrinkwrap.json</code> file. They are just not
  257. physically installed on disk.</p>
  258. <p>If a package type appears in both the <code>--include</code> and <code>--omit</code> lists, then
  259. it will be included.</p>
  260. <p>If the resulting omit list includes <code>'dev'</code>, then the <code>NODE_ENV</code> environment
  261. variable will be set to <code>'production'</code> for all lifecycle scripts.</p>
  262. <h4 id="include"><code>include</code></h4>
  263. <ul>
  264. <li>Default:</li>
  265. <li>Type: "prod", "dev", "optional", or "peer" (can be set multiple times)</li>
  266. </ul>
  267. <p>Option that allows for defining which types of dependencies to install.</p>
  268. <p>This is the inverse of <code>--omit=&lt;type&gt;</code>.</p>
  269. <p>Dependency types specified in <code>--include</code> will not be omitted, regardless of
  270. the order in which omit/include are specified on the command-line.</p>
  271. <h4 id="link"><code>link</code></h4>
  272. <ul>
  273. <li>Default: false</li>
  274. <li>Type: Boolean</li>
  275. </ul>
  276. <p>Used with <code>npm ls</code>, limiting output to only those packages that are linked.</p>
  277. <h4 id="package-lock-only"><code>package-lock-only</code></h4>
  278. <ul>
  279. <li>Default: false</li>
  280. <li>Type: Boolean</li>
  281. </ul>
  282. <p>If set to true, the current operation will only use the <code>package-lock.json</code>,
  283. ignoring <code>node_modules</code>.</p>
  284. <p>For <code>update</code> this means only the <code>package-lock.json</code> will be updated,
  285. instead of checking <code>node_modules</code> and downloading dependencies.</p>
  286. <p>For <code>list</code> this means the output will be based on the tree described by the
  287. <code>package-lock.json</code>, rather than the contents of <code>node_modules</code>.</p>
  288. <h4 id="unicode"><code>unicode</code></h4>
  289. <ul>
  290. <li>Default: false on windows, true on mac/unix systems with a unicode locale,
  291. as defined by the <code>LC_ALL</code>, <code>LC_CTYPE</code>, or <code>LANG</code> environment variables.</li>
  292. <li>Type: Boolean</li>
  293. </ul>
  294. <p>When set to true, npm uses unicode characters in the tree output. When
  295. false, it uses ascii characters instead of unicode glyphs.</p>
  296. <h4 id="workspace"><code>workspace</code></h4>
  297. <ul>
  298. <li>Default:</li>
  299. <li>Type: String (can be set multiple times)</li>
  300. </ul>
  301. <p>Enable running a command in the context of the configured workspaces of the
  302. current project while filtering by running only the workspaces defined by
  303. this configuration option.</p>
  304. <p>Valid values for the <code>workspace</code> config are either:</p>
  305. <ul>
  306. <li>Workspace names</li>
  307. <li>Path to a workspace directory</li>
  308. <li>Path to a parent workspace directory (will result in selecting all
  309. workspaces within that folder)</li>
  310. </ul>
  311. <p>When set for the <code>npm init</code> command, this may be set to the folder of a
  312. workspace which does not yet exist, to create the folder and set it up as a
  313. brand new workspace within the project.</p>
  314. <p>This value is not exported to the environment for child processes.</p>
  315. <h4 id="workspaces"><code>workspaces</code></h4>
  316. <ul>
  317. <li>Default: null</li>
  318. <li>Type: null or Boolean</li>
  319. </ul>
  320. <p>Set to true to run the command in the context of <strong>all</strong> configured
  321. workspaces.</p>
  322. <p>Explicitly setting this to false will cause commands like <code>install</code> to
  323. ignore workspaces altogether. When not set explicitly:</p>
  324. <ul>
  325. <li>Commands that operate on the <code>node_modules</code> tree (install, update, etc.)
  326. will link workspaces into the <code>node_modules</code> folder. - Commands that do
  327. other things (test, exec, publish, etc.) will operate on the root project,
  328. <em>unless</em> one or more workspaces are specified in the <code>workspace</code> config.</li>
  329. </ul>
  330. <p>This value is not exported to the environment for child processes.</p>
  331. <h4 id="include-workspace-root"><code>include-workspace-root</code></h4>
  332. <ul>
  333. <li>Default: false</li>
  334. <li>Type: Boolean</li>
  335. </ul>
  336. <p>Include the workspace root when workspaces are enabled for a command.</p>
  337. <p>When false, specifying individual workspaces via the <code>workspace</code> config, or
  338. all workspaces via the <code>workspaces</code> flag, will cause npm to operate only on
  339. the specified workspaces, and not on the root project.</p>
  340. <p>This value is not exported to the environment for child processes.</p>
  341. <h4 id="install-links"><code>install-links</code></h4>
  342. <ul>
  343. <li>Default: false</li>
  344. <li>Type: Boolean</li>
  345. </ul>
  346. <p>When set file: protocol dependencies will be packed and installed as regular
  347. dependencies instead of creating a symlink. This option has no effect on
  348. workspaces.</p>
  349. <h3 id="see-also">See Also</h3>
  350. <ul>
  351. <li><a href="../using-npm/package-spec.html">package spec</a></li>
  352. <li><a href="../commands/npm-explain.html">npm explain</a></li>
  353. <li><a href="../commands/npm-config.html">npm config</a></li>
  354. <li><a href="../configuring-npm/npmrc.html">npmrc</a></li>
  355. <li><a href="../configuring-npm/folders.html">npm folders</a></li>
  356. <li><a href="../commands/npm-explain.html">npm explain</a></li>
  357. <li><a href="../commands/npm-install.html">npm install</a></li>
  358. <li><a href="../commands/npm-link.html">npm link</a></li>
  359. <li><a href="../commands/npm-prune.html">npm prune</a></li>
  360. <li><a href="../commands/npm-outdated.html">npm outdated</a></li>
  361. <li><a href="../commands/npm-update.html">npm update</a></li>
  362. </ul></div>
  363. <footer id="edit">
  364. <a href="https://github.com/npm/cli/edit/latest/docs/lib/content/commands/npm-ls.md">
  365. <svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
  366. <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>
  367. </svg>
  368. Edit this page on GitHub
  369. </a>
  370. </footer>
  371. </section>
  372. </body></html>