node.js available global - How to list npm user-installed packages?

6 Answers

You can get a list of all globally installed modules using:

ls `npm root -g`

versions check if

How do I list the user-installed package ONLY in npm? When I do npm -g list it outputs every package and their dependencies, which is not what I want.

For local modules:

npm list --depth=0

For global modules:

npm list -g --depth=0

For project dependencies use:

npm list --depth=0

For global dependencies use:

npm list -g --depth=0

One way might be to find the root directory of modules using:

npm root

And then list that directory...

ls /Users/me/repos/my_project/node_modules
grunt                   grunt-contrib-jshint

The user-installed packages in this case are grunt and grunt-contrib-jshint

Node has a concept of Local modules & Global modules

Local modules are located within current project directory.

Global Modules are generally located at user's home directory, though we can change the path where global modules resides.

  1. Lists local modules within current dir: npm list
  2. Lists global modules : npm list --global OR npm list --g // It will list all the top level modules with its dependencies
  3. List only top level(Installed modules) global modules : npm list -g --depth=0

I use npm -g outdated --depth=0 to list outdated versions
in the global space.