How to list npm user-installed packages?

Better Stack Team
Updated on March 11, 2024

To list npm user-installed packages, you can use the npm list command in the terminal. By default, this command will show a tree-like structure of all installed packages for the current project. If you want to see a list of globally installed packages (user-installed), you can add the -g flag.

Here are the commands:

List User-Installed Packages Locally:

 
npm list

This command will display a tree structure of locally installed packages for the current project.

List User-Installed Packages Globally:

 
npm list -g --depth=0
  • g flag indicates global packages.
  • -depth=0 flag specifies that you only want to see top-level packages without their dependencies.

Alternatively, you can use the following command to list globally installed packages without the dependencies:

 
npm -g ls --depth=0

These commands will output a list of globally installed packages along with their versions. If you want more details, you can remove the --depth=0 flag, and npm will display the entire dependency tree.

Remember that the exact command might vary slightly based on your operating system and terminal environment.