How to list npm user-installed packages in Node.js

The npm list command provides an overview of the installed npm packages in your current project. The output can be extensive, especially if your project has many dependencies.

List Globally Installed Packages

To list npm user-installed packages globally in Node.js, you can use the “npm list -g –depth=0” command.

Here:

  1. -g stands for “global”. It tells npm to list globally installed packages.
  2. –depth=0 ensures you only see the top-level packages, not their dependencies.

List Globally Installed Packages using npm

List Locally Installed Packages

To list the packages you have installed locally (current project), navigate to the project’s directory and use the “npm list –depth=0” command.

Here:

  1. –depth=0 ensures you only see the top-level packages, not their dependencies.

List Locally Installed Packages

Outdated Packages

To check which of your installed packages are outdated (either globally or locally), you can use:

npm outdated -g # For globally installed packages

OR

npm outdated # For locally installed packages

Outdated Packages

You can see the output shows you the current version you have, the latest version available, and the version that your package.json file (if you have one) wants you to have.

That’s it!

Leave a Comment