简体   繁体   English

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

[英]list all globally installed modules with one command in ubuntu

I'm working on ubuntu 14.04 , Is there any way to print all global modules (installed using npm ) to the command line.我正在开发ubuntu 14.04 ,有没有办法将所有全局模块(使用npm安装)打印到命令行。 How can I do this?我怎样才能做到这一点?

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

npm ls -g --depth 0

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

My preferred method is to use the npmlist package, which can be installed using npm i -g npmlist .我的首选方法是使用npmlist包,它可以使用npm i -g npmlist安装。 Then you just use the npmlist command to get a formatted and color listing with versions of all global packages.然后,您只需使用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]

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

ls -l $(npm root -g)

To see the list of all globally installed modules type the following command:要查看所有全局安装模块的列表,请键入以下命令:

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.即使有未满足的依赖项,也将被列出。

The previous global and local flags are now deprecated.以前的全局和本地标志现在已弃用。 The preferred syntax today is as follows:今天的首选语法如下:

npm list --location=global --depth 0
npm ls   --location=global --depth 0
npm la   --location=global --depth 0
npm ll   --location=global --depth 0

npmlist=$(npm list --location=global --depth 0)
npmlist

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM