node.js 在 ubuntu 中使用一个命令列出所有全局安装的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40593660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 17:49:38  来源:igfitidea点击:

list all globally installed modules with one command in ubuntu

node.jsnpmubuntu-14.04npm-cli

提问by Muhsin Keloth

I'm working on ubuntu 14.04, Is there any way to print all global modules (installed using npm) to the command line. How can I do this?

我正在研究ubuntu 14.04,有什么方法可以将所有全局模块(使用 安装npm)打印到命令行。我怎样才能做到这一点?

回答by Muhsin Keloth

The below command will list all your globally installed modules on Linux, Mac, and Windows.

以下命令将列出您在 Linux、Mac 和 Windows 上全局安装的所有模块。

npm ls -g --depth 0

回答by etoxin

To list all globally installed modules run:

要列出所有全局安装的模块,请运行:

npm ls -g --depth 0

or yarn

或纱线

yarn global ls --depth 0

Extras:

附加功能:

To get a short module description run:

要获得简短的模块描述,请运行:

npm ll -g --depth 0

To see the path of where the global modules are installed run:

要查看安装全局模块的路径,请运行:

npm ls -gp --depth 0

回答by Michael P. Bazos

Much faster command than the selected answer, if you care only about listing package name and not the package version:

如果您只关心列出包名称而不是包版本,则命令比所选答案快得多:

ls -l $(npm root -g)

回答by Matthew Rankin

My preferred method is to use the npmlistpackage, which can be installed using npm i -g npmlist. Then you just use the npmlistcommand to get a formatted and color listing with versions of all global packages.

我的首选方法是使用npmlist包,它可以使用npm i -g npmlist. 然后您只需使用该npmlist命令即可获取所有全局包版本的格式化和颜色列表。

$ npmlist

Installed npm packages: (global)

@vue/cli.................[3.5.1]
browser-sync............[2.26.3]
degit....................[2.1.3]
eslint..................[5.15.3]
eslint-plugin-vue........[5.2.2]
jsonlint.................[1.6.3]
npm......................[6.9.0]
npmlist..................[3.1.2]
prettier................[1.16.4]
serverless..............[1.39.1]

回答by Nikhita zulka

To see the list of all globally installed modules type the following command:

要查看所有全局安装模块的列表,请键入以下命令:

npm ls -g --depth 0

npm ls -g --depth 0

this will give you the list of all the installed modules along with their versions. Even unmet dependencies if any, will also be listed.

这将为您提供所有已安装模块的列表及其版本。甚至未满足的依赖项(如果有)也将被列出。