1NPM-LS(1)                                                            NPM-LS(1)
2
3
4

NAME

6       npm-ls - List installed packages
7
8   Synopsis
9         npm ls <package-spec>
10
11         alias: list
12
13   Description
14       This command will print to stdout all the versions of packages that are
15       installed, as well as their dependencies when --all is specified, in  a
16       tree structure.
17
18       Note:  to get a "bottoms up" view of why a given package is included in
19       the tree at all, use npm help explain.
20
21       Positional arguments are  name@version-range  identifiers,  which  will
22       limit  the  results  to only the paths to the packages named. Note that
23       nested packages will also show the paths to the specified packages. For
24       example, running npm ls promzard in npm's source tree will show:
25
26         npm@10.2.3 /path/to/npm
27         └─┬ init-package-json@0.0.4
28           └── promzard@0.1.5
29
30       It will print out extraneous, missing, and invalid packages.
31
32       If  a  project  specifies  git urls for dependencies these are shown in
33       parentheses after the name@version to make it easier for users to  rec‐
34       ognize potential forks of a project.
35
36       The  tree shown is the logical dependency tree, based on package depen‐
37       dencies, not the physical layout of your node_modules folder.
38
39       When run as ll or la, it shows extended information by default.
40
41   Note: Design Changes Pending
42       The npm ls command's output and behavior made a ton of sense  when  npm
43       created  a node_modules folder that naively nested every dependency. In
44       such a case, the logical dependency graph and physical tree of packages
45       on disk would be roughly identical.
46
47       With the advent of automatic install-time deduplication of dependencies
48       in npm v3, the ls output was modified to display the logical dependency
49       graph  as  a  tree structure, since this was more useful to most users.
50       However, without using npm ls -l, it became impossible to show where  a
51       package was actually installed much of the time!
52
53       With  the  advent  of automatic installation of peerDependencies in npm
54       v7, this gets even more curious, as peerDependencies are logically "un‐
55       derneath"  their  dependents  in  the  dependency graph, but are always
56       physically at or above their location on disk.
57
58       Also, in the years since npm got an ls command (in version 0.0.2!), de‐
59       pendency  graphs  have gotten much larger as a general rule. Therefore,
60       in order to avoid dumping an excessive amount of content to the  termi‐
61       nal,  npm ls now only shows the top level dependencies, unless --all is
62       provided.
63
64       A thorough re-examination of the use cases,  intention,  behavior,  and
65       output  of  this  command,  is  currently  underway. Expect significant
66       changes to at least the default human-readable npm ls output in npm v8.
67
68   Configuration
69   all
70       •   Default: false
71
72       •   Type: Boolean
73
74
75       When running npm outdated and npm ls, setting --all will show all  out‐
76       dated  or  installed packages, rather than only those directly depended
77       upon by the current project.
78
79   json
80       •   Default: false
81
82       •   Type: Boolean
83
84
85       Whether or not to output JSON data, rather than the normal output.
86
87       •   In npm pkg set it enables parsing set values with JSON.parse()  be‐
88           fore saving them to your package.json.
89
90
91       Not supported by all npm commands.
92
93   long
94       •   Default: false
95
96       •   Type: Boolean
97
98
99       Show extended information in ls, search, and help-search.
100
101   parseable
102       •   Default: false
103
104       •   Type: Boolean
105
106
107       Output  parseable  results from commands that write to standard output.
108       For npm search, this will be tab-separated table format.
109
110   global
111       •   Default: false
112
113       •   Type: Boolean
114
115
116       Operates in "global" mode, so that packages are installed into the pre‐
117       fix folder instead of the current working directory. See npm help fold‐
118       ers for more on the differences in behavior.
119
120       •   packages are installed into the  {prefix}/lib/node_modules  folder,
121           instead of the current working directory.
122
123       •   bin files are linked to {prefix}/bin
124
125       •   man pages are linked to {prefix}/share/man
126
127
128   depth
129       •   Default: Infinity if --all is set, otherwise 1
130
131       •   Type: null or Number
132
133
134       The depth to go when recursing packages for npm ls.
135
136       If  not  set,  npm  ls will show only the immediate dependencies of the
137       root project. If --all is set, then npm will show all  dependencies  by
138       default.
139
140   omit
141       •   Default: 'dev' if the NODE_ENV environment variable is set to 'pro‐
142           duction', otherwise empty.
143
144       •   Type: "dev", "optional", or "peer" (can be set multiple times)
145
146
147       Dependency types to omit from the installation tree on disk.
148
149       Note that these dependencies are still resolved and added to the  pack‐
150       age-lock.json or npm-shrinkwrap.json file. They are just not physically
151       installed on disk.
152
153       If a package type appears in both the --include and --omit lists,  then
154       it will be included.
155
156       If  the  resulting omit list includes 'dev', then the NODE_ENV environ‐
157       ment variable will be set to 'production' for all lifecycle scripts.
158
159   include
160       •   Default:
161
162       •   Type: "prod", "dev", "optional", or "peer"  (can  be  set  multiple
163           times)
164
165
166       Option that allows for defining which types of dependencies to install.
167
168       This is the inverse of --omit=<type>.
169
170       Dependency types specified in --include will not be omitted, regardless
171       of the order in which omit/include are specified on the command-line.
172
173   link
174       •   Default: false
175
176       •   Type: Boolean
177
178
179       Used with npm ls, limiting output  to  only  those  packages  that  are
180       linked.
181
182   package-lock-only
183       •   Default: false
184
185       •   Type: Boolean
186
187
188       If  set  to  true,  the  current  operation  will only use the package-
189       lock.json, ignoring node_modules.
190
191       For update this means only the package-lock.json will be  updated,  in‐
192       stead of checking node_modules and downloading dependencies.
193
194       For  list  this means the output will be based on the tree described by
195       the package-lock.json, rather than the contents of node_modules.
196
197   unicode
198       •   Default: false on windows, true on mac/unix systems with a  unicode
199           locale,  as  defined  by  the LC_ALL, LC_CTYPE, or LANG environment
200           variables.
201
202       •   Type: Boolean
203
204
205       When set to true, npm uses unicode characters in the tree output.  When
206       false, it uses ascii characters instead of unicode glyphs.
207
208   workspace
209       •   Default:
210
211       •   Type: String (can be set multiple times)
212
213
214       Enable running a command in the context of the configured workspaces of
215       the current project while filtering by running only the workspaces  de‐
216       fined by this configuration option.
217
218       Valid values for the workspace config are either:
219
220       •   Workspace names
221
222       •   Path to a workspace directory
223
224       •   Path  to a parent workspace directory (will result in selecting all
225           workspaces within that folder)
226
227
228       When set for the npm init command, this may be set to the folder  of  a
229       workspace  which does not yet exist, to create the folder and set it up
230       as a brand new workspace within the project.
231
232       This value is not exported to the environment for child processes.
233
234   workspaces
235       •   Default: null
236
237       •   Type: null or Boolean
238
239
240       Set to true to run  the  command  in  the  context  of  all  configured
241       workspaces.
242
243       Explicitly  setting  this  to false will cause commands like install to
244       ignore workspaces altogether. When not set explicitly:
245
246       •   Commands that operate on the node_modules  tree  (install,  update,
247           etc.) will link workspaces into the node_modules folder. - Commands
248           that do other things (test, exec, publish, etc.)  will  operate  on
249           the  root  project,  unless one or more workspaces are specified in
250           the workspace config.
251
252
253       This value is not exported to the environment for child processes.
254
255   include-workspace-root
256       •   Default: false
257
258       •   Type: Boolean
259
260
261       Include the workspace root when workspaces are enabled for a command.
262
263       When false, specifying individual workspaces via the workspace  config,
264       or  all  workspaces  via the workspaces flag, will cause npm to operate
265       only on the specified workspaces, and not on the root project.
266
267       This value is not exported to the environment for child processes.
268
269   install-links
270       •   Default: false
271
272       •   Type: Boolean
273
274
275       When set file: protocol dependencies will be packed  and  installed  as
276       regular  dependencies instead of creating a symlink. This option has no
277       effect on workspaces.
278
279   See Also
280       •   npm help "package spec"
281
282       •   npm help explain
283
284       •   npm help config
285
286       •   npm help npmrc
287
288       •   npm help folders
289
290       •   npm help explain
291
292       •   npm help install
293
294       •   npm help link
295
296       •   npm help prune
297
298       •   npm help outdated
299
300       •   npm help update
301
302
303
304                                 November 2023                       NPM-LS(1)
Impressum