Check out our Angular Book Series.

How do I get the versions of all installed Node Modules?

I've been working on an Angular project with my team, and we ran into a situation where tests were failing for a couple of team members, but working fine for everyone else. It was infuriating. We decided the issue must be with a version mismatch of some library, as opposed to the test itself.

Node libraries, by definition, have a lot of inner dependencies. How do we get a list of all the top level libraries installed on each user's respective machine? It's easy:

npm list -global -depth 0

The npm list command will give you the list. The `-global` flag will tell you to list all node packages installed globally.

The depth will give us the top level package, but none of the internal dependencies.

Run this and I get something like this:

I only have the Angular CLI installed globally.

To get a list of locally installed libraries, you can just drop out the global flag:

npm list -depth 0

If you want see the full list of dependencies, you can leave out the depth argument entirely.

Using this approach, we were able to determine the differences in installed base of the affected users vs the ones who could still run tests. It was a good first step in debugging the issue.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Comments are not allowed for this entry.
All Content Copyright 2005, 2006, 2007, 2008, 2009 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version