-
-
Save yyx990803/6045243 to your computer and use it in GitHub Desktop.
| alias ng="npm list -g --depth=0 2>/dev/null" | |
| alias nl="npm list --depth=0 2>/dev/null" |
Note that options like --depth 0 can be set in npm's config as well.
So to make npm ls work more like *nix ls -l i.e. show only the top-level modules, you can run:
npm config set depth 0Of course, you can always override this config setting from the command line, so to restore the original behaviour, i.e. make npm ls work more like *nix ls -lR, you can run:
npm ls -g --depth 9999Note that setting depth in config also applies to npm la, npm ll, npm ls --long, etc., so no need to define shell aliases for any of those either.
Check this out npm ls -ps
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?
Why does the --depth option not appear in npm -h nor npm list -h ? Is this an hidden option?
Why does the --depth option not appear in
npm -hnornpm list -h? Is this an hidden option?
I tried looking for it too. I think it's just undocumented.
Thanks, based on this info I wrote a small bash script, usage can be
npl,npl 0,npl 1,npl 2 g,npl g,npl -hetc.where 0,1,.. is the level and g is global, of course. Hope it helps someone.
(Don't forget to put it in a folder in your path and to
chmod +xit.)http://awadev.com/npl