簡體   English   中英

在 ubuntu 中使用一個命令列出所有全局安裝的模塊

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

我正在開發ubuntu 14.04 ,有沒有辦法將所有全局模塊(使用npm安裝)打印到命令行。 我怎樣才能做到這一點?

以下命令將列出您在 Linux、Mac 和 Windows 上全局安裝的所有模塊。

npm ls -g --depth 0

要列出所有全局安裝的模塊,請運行:

npm ls -g --depth 0

或紗線

yarn global ls --depth 0

附加功能:

要獲得簡短的模塊描述,請運行:

npm ll -g --depth 0

要查看安裝全局模塊的路徑,請運行:

npm ls -gp --depth 0

我的首選方法是使用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]

如果您只關心列出包名稱而不關心包版本,則命令比所選答案快得多:

ls -l $(npm root -g)

要查看所有全局安裝模塊的列表,請鍵入以下命令:

npm ls -g --depth 0

這將為您提供所有已安裝模塊及其版本的列表。 即使有未滿足的依賴項,也將被列出。

以前的全局和本地標志現在已棄用。 今天的首選語法如下:

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