0

I just want to get a snapshot of what's installed locally in a project and what's installed globally:

npm whats-installed-locally
npm whats-installed-globally
npm whats-dependencies-between-local-global-repos

What's the proper command-line sequence?

Also, is there a way to determine which dependencies are being unhinged between the two repositories?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kent
  • 81
  • 1
  • 1
  • 4
  • for globally use > node list. further info: > npm help list – bsorrentino Jan 15 '15 at 20:41
  • The canonical question is *[Find the version of an installed npm package](https://stackoverflow.com/questions/10972176/)*. The top answer is identical (and then some) to the answer here. – Peter Mortensen Aug 05 '22 at 01:54

1 Answers1

2

To list the local installed npm packages:

npm list

To list the globally installed npm packages:

npm list -g
John Petrone
  • 26,943
  • 6
  • 63
  • 68
  • 2
    adding `--depth=0` to the end of either of these will limit what is shown to just the root level entries and avoid showing all of their dependencies. – Jason Aller Jan 15 '15 at 23:40
  • For the latter, there is a warning (to [standard error](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr))): *"npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead."*. It was observed with npm 8.11.0. – Peter Mortensen Aug 04 '22 at 22:40
  • If a package name is appended, it can be used to test for the installed state of a package. The return code will be 0 if it is installed or different from 0 if it is not installed (and there will screen output as well (to [standard output](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_.28stdout.29))). Example, testing if Jest is installed: `npm list -g jest` – Peter Mortensen Aug 04 '22 at 22:45
  • [An answer](https://stackoverflow.com/questions/26104276/how-to-tell-if-an-npm-package-was-installed-globally-or-locally/31209501#31209501) addressing that. – Peter Mortensen Aug 05 '22 at 00:28