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