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

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


当前回答

对于项目依赖使用:

npm list --depth=0

对于全局依赖使用:

npm list -g --depth=0

其他回答

对于项目依赖使用:

npm list --depth=0

对于全局依赖使用:

npm list -g --depth=0

你可以试试NPM桌面管理器:

只需单击一下,您就可以在dev或全局状态下安装/卸载包。

我使用npm -g outdated——depth=0来列出全局空间中过时的版本。

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

npm ls -g --depth=0

一种方法可能是使用以下命令找到模块的根目录:

npm root

输出:

    /Users/me/repos/my_project/node_modules

然后列出该目录…

ls /Users/me/repos/my_project/node_modules

输出:

    grunt                   grunt-contrib-jshint

在本例中,用户安装的包是grunt和grunt-contrib-jshint。