Skip to main content
Version: 11.x

pnpm list

别名:ls

🌐 Aliases: ls

此命令将输出已安装软件包的所有版本以及它们的依赖,并以树状结构显示。

🌐 This command will output all the versions of packages that are installed, as well as their dependencies, in a tree-structure.

位置参数是 name-pattern@version-range 标识符,它们将限制结果仅包含指定名称的软件包。例如,pnpm list "babel-*" "eslint-*" semver@5

🌐 Positional arguments are name-pattern@version-range identifiers, which will limit the results to only the packages named. For example, pnpm list "babel-*" "eslint-*" semver@5.

选项

🌐 Options

--recursive, -r

在工作区内执行时,对子目录中的每个包或每个工作区包执行命令。

🌐 Perform command on every package in subdirectories or on every workspace package, when executed inside a workspace.

--json

JSON 格式的日志输出。

🌐 Log output in JSON format.

--long

显示扩展信息。

🌐 Show extended information.

--lockfile-only

新增于:v10.23.0

🌐 Added in: v10.23.0

从锁定文件中读取包信息,而不是检查实际的 node_modules 目录。这对于快速查看将要安装的内容非常有用,而无需进行完整安装。

🌐 Read package information from the lockfile instead of checking the actual node_modules directory. This is useful for quickly inspecting what would be installed without requiring a full installation.

--parseable

以可解析的格式输出包目录而不是树视图。

🌐 Outputs package directories in a parseable format instead of their tree view.

--global, -g

列出全局安装目录中的包,而不是当前项目中的包。

🌐 List packages in the global install directory instead of in the current project.

--depth <number>

依赖树的最大显示深度。

🌐 Max display depth of the dependency tree.

pnpm ls --depth 0(默认)将仅列出直接依赖。 pnpm ls --depth -1 将仅列出项目。在使用 -r 选项时,在工作区内非常有用。 pnpm ls --depth Infinity 将列出所有依赖,无论深度如何。

--prod, -P

仅显示 dependenciesoptionalDependencies 中软件包的依赖图。

🌐 Display only the dependency graph for packages in dependencies and optionalDependencies.

--dev, -D

仅显示 devDependencies 中软件包的依赖图。

🌐 Display only the dependency graph for packages in devDependencies.

--no-optional

不要显示来自 optionalDependencies 的软件包。

🌐 Don't display packages from optionalDependencies.

--only-projects

仅显示也是工作区中的项目的依赖。

🌐 Display only dependencies that are also projects within the workspace.

--exclude-peers

从结果中排除对等依赖(但不会忽略对等依赖的依赖)。

🌐 Exclude peer dependencies from the results (but dependencies of peer dependencies are not ignored).

--filter <package_selector>

了解更多关于筛选的信息。

--find-by <finder_name>

新增于:v10.16.0

🌐 Added in: v10.16.0

使用在 .pnpmfile.mjs 中定义的 finder function 来根据除名称以外的属性匹配依赖。

🌐 Use a finder function defined in .pnpmfile.mjs to match dependencies by properties other than name.