HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptCritical

How to list npm user-installed packages?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
hownpmpackagesuserlistinstalled

Problem

How do I list the user-installed / environment package only in npm?

When I do npm -g list, it outputs every package and their dependencies. Instead I'd like to see the packages installed in the current working project or environment.

Solution

npm list -g --depth=0 --json


  • npm: the Node.js package manager command line tool



  • list -g: display a tree of every package found in the user’s folders (without the -g option it only shows the current directory’s packages)



  • --depth 0 / --depth=0: avoid including every package’s dependencies in the tree view



  • --json(optional): This will output a JSON object with the dependencies field containing the user-installed packages.

Context

Stack Overflow Q#17937960, score: 2072

Revisions (0)

No revisions yet.