Skip to content

Instantly share code, notes, and snippets.

@yyx990803
Last active March 5, 2024 01:24
Show Gist options
  • Save yyx990803/6045243 to your computer and use it in GitHub Desktop.
Save yyx990803/6045243 to your computer and use it in GitHub Desktop.
npm list only top level modules.
alias ng="npm list -g --depth=0 2>/dev/null"
alias nl="npm list --depth=0 2>/dev/null"
@richworx
Copy link

richworx commented Aug 8, 2019

This doesn't seem to work for node installed by nvm. I have to use --depth=1 to see the installed packages. Does anyone have a solution that works for both (or an easy way to detect whether the running npm is from nvm or not?

@Hibou57
Copy link

Hibou57 commented Apr 24, 2020

Why does the --depth option not appear in npm -h nor npm list -h ? Is this an hidden option?

@skyrpex
Copy link

skyrpex commented Jan 25, 2021

Why does the --depth option not appear in npm -h nor npm list -h ? Is this an hidden option?

I tried looking for it too. I think it's just undocumented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment