Listing Installed npm Packages
npm·3 min read·Jan 1, 2025
Being able to list the packages used by a project is quite helpful as it allows developers to better understand how packages are built in general, control the size of their applications, fix package-related bugs or conflicts by downgrading or bumping package versions, replace unmaintained packages, and so on.
Listing installed packages
Listing locally installed packages
To output the list of top-level packages installed in the node_modules directory of a project, you can navigate to the project, and run the npm ls command:
$ npm lsExample
For example, this command will show the top-level packages of the website project:
$ npm lswebsite@1.0.0 /Users/rludosanu/Projects/website├── axios@1.4.0└── dayjs@1.11.9Listing globally installed packages
To output the list of top-level packages installed globally on the system, you can use the npm ls with the -g flag:
$ npm ls -gExample
For example, this command will show the globally installed top-level packages:
Unlock the Build CLI Apps in JavaScript & Node.js module
Learn how to build, integrate, and safeguard scalable CLI tools, scripts, and apps with JavaScript, Node.js, npm, and Git.
You get immediate access to:
- 45 focused lessons across JavaScript, Node.js, npm, and Git
- 17 real-world projects with commented solutions
- Ongoing updates to this bundle
- Lifetime access to this bundle