我如何列出用户安装/环境包只在npm?

当我执行npm -g list时,它会输出每个包及其依赖项。相反,我希望看到包安装在当前工作的项目或环境中。


当前回答

npm list -g --depth=0

npm: Node.js包管理器命令行工具 List -g:显示在用户文件夹中找到的每个包的树(没有-g选项,它只显示当前目录的包) ——depth 0 /——depth=0:避免在树视图中包含每个包的依赖项

其他回答

作为一种简写,你可以运行:

npm ls -g --depth=0

你可以使用以下命令获取所有全局安装模块的列表:

ls `npm root -g`

对于本地模块,使用usenpm list——depth 0。

对于全局模块,使用npm list -g——depth 0。

示例:本地npm模块

示例:全局npm模块

使用npm列表和使用grep过滤包含

例子:

npm list -g | grep name-of-package

Use:

npm ls

NPM list只是NPM ls的别名。

对于扩展的信息,使用:

npm la
npm ll

你总是可以在最后设置——depth=0来获得第一个层次的深度。

npm ls --depth=0

您可以检查开发包和生产包。

npm ls --only=dev
npm ls --only=prod

以json格式显示信息

npm ls --json=true

默认为false

npm ls --json=false

您可以坚持使用长格式来显示扩展的信息。

npm ls --long=true

您可以显示可解析的输出,而不是树视图。

npm ls --parseable=true

您可以在全局安装前缀中而不是在当前项目中列出包。

npm ls --global=true
npm ls -g // shorthand

你可以在这里找到完整的文档。