1 ---
2 title: npm-ls
3 section: 1
4 description: List installed packages
5 github_repo: npm/cli
6 github_branch: release/v7
7 github_path: docs/content/commands/npm-ls.md
8 redirect_from:
9 - /cli-documentation/v7/cli-commands/ls
10 - /cli-documentation/v7/cli-commands/npm-ls
11 - /cli-documentation/v7/commands/ls
12 - /cli-documentation/v7/commands/npm-ls
13 - /cli-documentation/v7/ls
14 - /cli-documentation/v7/npm-ls
15 - /cli/v7/cli-commands/ls
16 - /cli/v7/cli-commands/npm-ls
17 - /cli/v7/commands/ls
18 - /cli/v7/ls
19 - /cli/v7/npm-ls
20 ---
21
22 ### Synopsis
23
24 ```bash
25 npm ls [[<@scope>/]<pkg> ...]
26
27 aliases: list, la, ll
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/v7/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@7.24.2 /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 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/v7/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 #### `link`
132
133 - Default: false
134 - Type: Boolean
135
136 Used with `npm ls`, limiting output to only those packages that are linked.
137
138 #### `package-lock-only`
139
140 - Default: false
141 - Type: Boolean
142
143 If set to true, the current operation will only use the `package-lock.json`, ignoring `node_modules`.
144
145 For `update` this means only the `package-lock.json` will be updated, instead of checking `node_modules` and downloading dependencies.
146
147 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`.
148
149 #### `unicode`
150
151 - 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.
152 - Type: Boolean
153
154 When set to true, npm uses unicode characters in the tree output. When false, it uses ascii characters instead of unicode glyphs.
155
156 #### `workspace`
157
158 - Default:
159 - Type: String (can be set multiple times)
160
161 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.
162
163 Valid values for the `workspace` config are either:
164
165 - Workspace names
166 - Path to a workspace directory
167 - Path to a parent workspace directory (will result to selecting all of the nested workspaces)
168
169 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.
170
171 This value is not exported to the environment for child processes.
172
173 #### `workspaces`
174
175 - Default: false
176 - Type: Boolean
177
178 Enable running a command in the context of **all** the configured workspaces.
179
180 This value is not exported to the environment for child processes.
181
182 ### See Also
183
184 - [npm explain](/cli/v7/commands/npm-explain)
185 - [npm config](/cli/v7/commands/npm-config)
186 - [npmrc](/cli/v7/configuring-npm/npmrc)
187 - [npm folders](/cli/v7/configuring-npm/folders)
188 - [npm explain](/cli/v7/commands/npm-explain)
189 - [npm install](/cli/v7/commands/npm-install)
190 - [npm link](/cli/v7/commands/npm-link)
191 - [npm prune](/cli/v7/commands/npm-prune)
192 - [npm outdated](/cli/v7/commands/npm-outdated)
193 - [npm update](/cli/v7/commands/npm-update)