When working with Node.js, you may install various NPM packages globally to use them across multiple projects. Over time, you may forget which global NPM packages are on your system.
In this article, we’ll explore how to list the global NPM packages on your system with code samples.
Listing the Global NPM Packages
To list the installed global NPM packages, you can use the following command in your terminal:
# List the installed global NPM packages
npm list -g --depth 0
This command will display the list of global NPM packages installed on your system.
-g or --global: The option to list global packages on your system.
--depth 0: The option to limit the depth of the dependency tree to zero. This will only list the top-level packages without their dependencies.
Listing the Global NPM Packages with Details
To list the installed global NPM packages with details, such as the version number and location, you can use the following command:
# List the installed global NPM packages with details
npm list -g --depth 0 --long
This command will display the list of global NPM packages installed on your system along with their version number and installation location.
- --long: The option to display additional information about each package, including its version and the location of its files on disk.
Checking the Version of a Global NPM Package
To check the version of a specific global NPM package, you can use the following command:
# Check the version of a specific global NPM package
npm list -g <package_name>
Replace with the name of the global NPM package you want to check.
npm list -g create-react-app
Conclusion
Listing the global NPM packages on your system is a simple process that can help you keep track of the NPM packages installed on your system.
Remember to periodically check the list of global NPM packages to keep your system up-to-date and avoid any conflicts or issues with your projects.
Top comments (0)