list all globally installed modules with one command in ubuntu
Asked Answered
B

6

85

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?

Blanchard answered 14/11, 2016 at 16:38 Comment(1)
npm list -g ?Swearword
B
183

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

npm ls -g --depth 0
Blanchard answered 16/11, 2016 at 15:10 Comment(2)
why is there such a massive difference with and without the --depth 0 option? Do I or don't I have all these dependencies installed globally as well?Intertype
The difference with --depth 0 is that with that option you are only listing packages that are directly globally installed. Without the depth option you are also listing all the packages that are dependencies of those packages.Eveleen
P
20

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
Peephole answered 19/6, 2018 at 6:55 Comment(0)
E
6

My preferred method is to use the npmlist package, which can be installed using 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

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]
Examinee answered 30/3, 2019 at 11:2 Comment(0)
A
3

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)
Antoinetteanton answered 21/12, 2018 at 12:49 Comment(1)
This doesn’t work for packages like @postlight/mercury-parser.Balcony
C
0

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.

Cluck answered 31/10, 2018 at 13:37 Comment(1)
It is the exact same command as in the accepted answer (which is the most visible answer)Antoinetteanton
S
0

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
Sillimanite answered 21/6, 2022 at 15:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.