DEV Community

Ahmet Ustun
Ahmet Ustun

Posted on • Originally published at ahmetustun.Medium

Listing the Globally Installed NPM Packages

Photo by [Carl Raw](https://unsplash.com/@carltraw?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/photos/m3hn2Kn5Bns?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

Replace with the name of the global NPM package you want to check.

npm list -g create-react-app
Enter fullscreen mode Exit fullscreen mode

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)