mnrqgq
Last Updated: February 25, 2016
·
7.472K
· icflorescu
Icflorescu

npm list --depth=0

You probably know npm list will give you a comprehensive report of the installed npm modules. The problem is you'll get the entire dependency-tree, while you're mostly interested in the top-level modules.

I've recently come across this quick way to list just the top-level modules, so I thought I should share it with you here:

npm list --depth=0

...or, if you want to list the globally-installed modules:

npm list --depth=0 -g

npm list --depth=0

Say Thanks
Respond

12 Responses
Add your response

11540
4693d7cfa88635d430c0de9a92f8dd84

Hi Ionut, this is very useful! Thanks for sharing!

over 1 year ago ·
11547
052ee0d106425f379a2a6d9f0c8187f1

neat!

over 1 year ago ·
11562
16996240 1811380019125112 7042258768267065705 n

really helpful!

over 1 year ago ·
11590

Great, but why a photo? I mean... even girls from advertisement department in my company take screenshots.

Is it already viral to be a geek and take photos of a display? If yes, I'm in :)

over 1 year ago ·
11596
Icflorescu

Thank you all for reading and for your comments!

@nemoden - I don't have an advertising department, but when I'll do, I'll make sure to teach the girls some post-processing effects :-P. Actually it is a screenshot, with a perspective effect. Some people like it, some hate it, but in the end more people tend to notice/remember those :-)...

over 1 year ago ·
11604
Author

Hi,

This is very useful, thanks for sharing! I have a - most probably npm newby - issue and I hope you will be able to help me out.

When I run npm list -depth=0 in my project folder after the level 1 list I get the following error messages:

npm ERR! max depth reached: devtools-terminal[@]0.0.1, required by
undefined[@]undefined
npm ERR! max depth reached: grunt-cli[@]0.1.11, required by undefined[@]undefined
npm ERR! max depth reached: grunt-init[@]0.2.1, required by undefined[@]undefined
npm ERR! max depth reached: jsdoc[@]3.2.0-dev, required by undefined[@]undefined
npm ERR! max depth reached: npm[@]1.3.2, required by undefined[@]undefined
npm ERR! max depth reached: yuidocjs[@]0.3.45, required by undefined[@]undefined
npm ERR! not ok code 0

Sorry for the [@]-s, I couldn't figure out how to get Coderwall to render the @ without wrapping them up as anchors.

Could you help me figuring out why I am getting these?

Cheers!

over 1 year ago ·
11622
57e15d6acbd5f46c300a83b5e61db1de

@heartcode try npm list --depth=0 "$@" 2>/dev/null (essentially ignore pointless errors by redirecting them to /dev/null)

over 1 year ago ·
11624
Icflorescu

@leecrossley thanks for pointing that out!

It's also worth saying that one could add something like this in his .profile in order to save typing:

alias npml="npm list --depth=0 "$@" 2>/dev/null"

over 1 year ago ·
11625
57e15d6acbd5f46c300a83b5e61db1de

@icflorescu yep, great point

over 1 year ago ·
11626
Icflorescu

The --depth=0 parameter also works for npm outdated...

over 1 year ago ·
11658
56f2e7e3ae23d6b5b803eb51e1d601fe

p r o t i p

nice one, the noise was bugging me!

over 1 year ago ·
13192
Icflorescu

Due to a bug in recent NPM versions, this doesn't work anymore, but you can use this hack instead.

over 1 year ago ·