npm-ls
List installed npm package dependencies
TLDR
Print all versions of direct dependencies to stdout
Print all installed packages including peer dependencies
Print dependencies with extended information
Print dependencies in parseable format
Print dependencies in JSON format
SYNOPSIS
npm ls [
npm ls -g [
PARAMETERS
Optional. If specified, lists only the matching packages. Supports name@version, where version can be a semver range.-g
, --global
Lists globally installed packages instead of packages in the current project.--depth
Sets the maximum depth of the dependency tree to display. Defaults to `Infinity`.--json
Outputs the dependency tree in JSON format.--long
Displays extended information about the packages.--parseable
Outputs in a parseable format (e.g., space-separated paths).--all
Show all outdated dependencies--omit
Omit packages that are of the specified type. Valid values: "dev"
, "optional"
, "peer"
(can specify multiple with comma delimited string).--include
Include packages that are of the specified type. Valid values: "dev"
, "optional"
, "peer"
(can specify multiple with comma delimited string).--link
List linked packages.
DESCRIPTION
The `npm ls` command is used to list the installed versions of all npm packages in a project. It displays the dependency tree, showing the hierarchy of packages and their dependencies. This command helps developers understand the structure of their project's dependencies, identify potential conflicts, and verify that the correct versions of packages are installed. The output provides valuable insights into the overall health and organization of a Node.js project. You can run `npm ls` in a project directory to see all the installed packages and their dependencies, or you can use it globally (`npm ls -g`) to see the globally installed packages. This is particularly useful for managing globally installed command-line tools. The command's output helps debug issues related to dependency versions and conflicts, contributing to the overall stability and maintainability of the project.
CAVEATS
The output of `npm ls` can be very verbose for projects with many dependencies. Consider using the `--depth` option to limit the output.
EXIT CODES
npm ls
exits with a code of 0 if it completes successfully. It exits with a non-zero code if it encounters errors, such as missing dependencies or invalid package configurations.
DEPENDENCY CONFLICTS
npm ls
highlights dependency conflicts in the output. This allows developers to quickly identify and resolve version mismatches that could lead to runtime errors.
HISTORY
The `npm ls` command has been a core part of npm since its early days. It was designed to provide a way to inspect the dependency tree of Node.js projects. Over time, its functionality has been extended with options like `--depth`, `--json`, and `--global` to provide more control over the output and scope of the listing. It continues to be a fundamental tool for Node.js developers to manage and understand their dependencies.
SEE ALSO
npm(1), npm-install(1), npm-uninstall(1), npm-update(1)