View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All

How to Get List of Globally Installed Packages of NPM

By Pavan Vadapalli

Updated on May 15, 2025 | 22 min read | 11.33K+ views

Share:

Did You Know?  As of February 2025, there are 1.9 million npm packages linked to GitHub repositories, providing a rich dataset for software engineering research!

NPM (Node Package Manager) is a tool that enables developers to share and install code packages i.e. collections of reusable functions and libraries that add specific functionality to projects. Using packages helps save time by preventing redundant coding and enhancing development speed. 

For example, NPM packages like Express simplify routing, and Lodash offers utility functions for arrays and objects. These pre-built solutions save developers time, letting them focus on the unique aspects of their application instead of writing common functionality from scratch.

This blog provides a detailed guide on accessing and managing globally installed NPM packages. It also covers how to optimize development workflows by effectively using these packages to increase efficiency and consistency in projects.

Programming is essential for developing efficient software, and mastering languages like JavaScript is crucialupGrad’s software engineering courses offer hands-on training in coding, problem-solving, and application development. Gain these skills to advance your career and tackle complex programming challenges with confidence!

Quickly List Your Globally Installed Packages with This Simple NPM Command

Managing globally installed packages in NPM is crucial for maintaining a clean and efficient development environment. One of the easiest ways to list these packages is by using the NPM CLI.

To view the list of globally installed NPM packages, use the command npm list -g --depth=0. This command displays all the globally installed packages on your system, allowing better management of the development environment.

npm list -g --depth=0

Here ‘–depth 0‘ signifies that only the top-level packages should be listed without their dependencies. If you wish to view the dependencies, you can always edit or omit this option.

Sample output:

/usr/local/lib
├── npm@10.2.3
├── typescript@5.2.4
├── eslint@8.50.0

Following this command will enable you to see all the packages, alongside their version numbers, installed in your system globally.

Furthermore, it also allows you to search for a specific package by filtering the list. You just have to add the package name that you wish to view at the end of the command. Mentioned below is a small example to help you understand the same. 

Filter for a Specific Package:

npm list -g express

In this manner, you can view details of that specific package only. 

Example: Let’s say you're working on multiple Node.js projects and you’ve installed some useful global packages like nodemon for auto-restarting your server and prettier for code formatting. To see which packages are globally installed on your system, you can use the following command:

npm ls -g --depth=0

Expected Output:

/usr/lib
├── nodemon@2.0.22
├── prettier@3.1.0

nodemon@2.0.2 is a globally installed package that automatically restarts the server when changes are made to the code. prettier@3.1.0 is used for code formatting, ensuring your code is consistently styled according to specified rules.

By using this simple command, you can quickly see what global tools and libraries are installed without diving into each individual package's dependencies. If you wish to see more details about the dependencies, you can increase the depth, like so:

npm ls -g --depth=2

This would show the nested dependencies of these packages, helping you manage your environment with ease.

Enhance your programming and software skills with courses that teach tools like Node Package Manager (NPM). Learn the techniques to streamline coding, manage dependencies, use AI,  and build scalable applications through courses like: 

Now that you’re familiar with listing globally installed packages with NPM CLI, let’s look at how you can use NPM Is Command.

Using npm ls Command for Global Package List

The ‘npm ls‘ is another method that you can use to list globally installed packages in your system. The command for the same goes as follows,

npm ls -g --depth=0

Output (tree-like):

/usr/lib
├── nodemon@2.0.22
├── prettier@3.1.0

It will generate a tree-like structure containing all the details of the global packages installed in your system, including their version numbers and dependencies. However, please note that this is only limited to the top-level packages. If you wish to view all the dependencies, you can simply alter “–depth=0” to a higher number.

To see deeper dependencies:

npm ls -g --depth=2

When running the command npm ls -g --depth=2, the output will display a tree-like structure showing global packages along with their dependencies. 

Here's an example output:

/usr/lib
├── nodemon@2.0.22
│   ├── chokidar@3.5.2
│   └── touch@3.1.0
├── prettier@3.1.0
│   ├── debug@4.3.4
│   └── eslint@7.32.0

This shows nodemon and prettier as global packages, along with their respective dependencies at depth 2. You can modify the depth to see more nested dependencies as needed.

Coverage of AWS, Microsoft Azure and GCP services

Certification8 Months

Job-Linked Program

Bootcamp36 Weeks

Get a good understanding of programming languages like Java with upGrad’s free Core Java Basics course. It covers variables, data types, loops, and OOP principles to build strong coding skills. Perfect for aspiring developers, students, and professionals transitioning to Java.

Also Read: How to Install a Specific Version of an NPM Package

Next, let’s look at how you can display package details with NPM view command.

Displaying Package Details with NPM view Command

The ‘npm view‘ command is commonly used to display detailed information about any specific package. This includes its version or dependencies and highlights details related to the author, license, and more.

It does so by running the following command,

npm view <package-name>

After entering this command, you will automatically get access to the latest version of the specific package alongside its metadata. 

To view metadata:

npm view express

If you are looking for one specific version of the package, you simply have to enter the version number after the package name. 

Let’s say you want to display the dependencies of the ronn package at version 0.2.4. The command for the same goes as follows, 

npm view ronn@0.2.4 dependencies. 

Similarly, the ‘npm view’ command also allows you to display specific metadata fields for any specific package. You simply have to enter the field name at the end of the name. 

npm view <package-name> <field-name>

The npm audit command is used to identify and fix vulnerabilities in the dependencies of your Node.js project. It scans your node_modules folder and package-lock.json file, providing a detailed report of any security issues, along with recommendations for updates or patches. 

Running npm audit regularly is essential for managing both local and global packages, helping to maintain a secure environment for your applications.

Example: Let’s say you're interested in viewing detailed information about the express package, one of the most popular web frameworks for Node.js. You can use the npm view command to get comprehensive details about this package.

Open your terminal and run the following command to view information about the express package:

npm view express

Output:

express@4.17.1
node_modules/express
├── accept@1.3.7
├── array-flatten@1.1.1
├── body-parser@1.19.0
├── content-disposition@0.5.3
├── cookie@0.4.1
...

express@4.17.1: This is the latest version of the Express package available on npm. The package details include the version, dependencies (like body-parser and cookie), and submodules that make up the express framework.

Specific Information: If you're interested in a specific detail, such as the package’s maintainers or the repository link, you can query those specifically with the npm view command:

  • To see the maintainers of the package:
npm view express maintainers

This will return the maintainers of the express package.

  • To see the repository link:
npm view express repository

This will show the GitHub link or other repository details for express.

Example Output for Maintainers:

[ { name: 'Rajesh Kumar <rajesh.kumar@npmjs.com>' },
  { name: 'Amit Patel <amit.patel@npmjs.com>' },
  { name: 'Sandeep Sharma <sandeep.sharma@npmjs.com>' } ]

This command helps you understand the structure and metadata of any npm package, making it easier to integrate into your projects and troubleshoot any issues.

The npm view command is a valuable tool for inspecting package details, verifying versions, and understanding a package's dependencies or maintainers without the need to install the package locally. It is especially useful for keeping track of the packages you plan to use in your development projects.

You can get to know more about Node.js with upGrad’s free Node.js For Beginners course. Learn to build scalable backend applications with this Node.js free course. Master Node.js fundamentals, architecture, and core modules.

Also ReadYarn vs NPM: Key Differences and How to Choose the Right Package Manager in 2025

With a clear understanding of how to display package details, the next step is finding outdated packages with NPM.

Finding Outdated Packages with NPM outdated Command

The ‘npm outdated’ command can spot any outdated packages in your system. It compares the currently installed packages with the latest version available in the npm registry. In this manner, it carefully presents any latest or newer version that might be available for the installed packages in your system.

In order to use ‘npm outdated,’ you simply have to run the following command,

npm outdated

After entering the command, you can view a detailed list containing the latest updates, current versions, and the type of upgrade required. 

Additionally, if you wish to check for any specific package, you can achieve the same by simply using this,

npm outdated <package-name>

There are two other methods in npm outdated command. They are, namely,

  • ‘–depth’ and 
  • ‘–json’

The ‘–depth’ option lets you narrow down how deep the dependency tree should be checked for outdated packages.

Take this one, for example, 

npm outdated -depth=2

Here, ‘–depth=2’ signifies that it will check two levels deep in the dependency tree for outdated packages. 

Contrary to this, the ‘–json’ is used to generate results in JSON format. This is helpful when you want to further process the results with other tools or scripts. 

Please note that ‘npm outdated‘ is an in-built command; that is, you do not have to install any additional packages for the same. 

Example: Imagine you're working on a project and have several npm packages installed. Over time, some of these packages might receive updates that improve performance, add new features, or fix security vulnerabilities. 

The npm outdated command allows you to quickly see which packages need to be updated.

npm outdated

Expected Output:

Package        Current   Wanted   Latest  Location
express        4.17.1    4.18.0   4.18.0  node_modules/express
mongoose       5.10.9    5.11.0   5.12.0  node_modules/mongoose
prettier       2.0.5     2.1.0    2.1.1   node_modules/prettier

The current version of the express package installed is 4.17.1, but the latest version is 4.18.0. The wanted version (the version specified in your package.json file) is 4.18.0. This means express is outdated and can be updated.

The installed version of mongoose is 5.10.9, but the latest available is 5.12.0, which suggests there are some minor updates and improvements you might want to consider.

The current version of prettier is 2.0.5, but a more recent version (2.1.1) is available.

This command is helpful in keeping your project’s dependencies up to date, ensuring you benefit from the latest features and security patches.

Updating Outdated Packages:

Once you’ve identified which packages are outdated, you can update them by running:

npm update

This command updates all outdated packages to the latest version that satisfies the version range in your package.json.

The npm outdated command is a quick way to identify which packages in your project need updates. It ensures that your project stays secure and takes advantage of the latest improvements in the packages you use.

If you want to improve your knowledge of object-oriented programming in Java, upGrad’s Java Object-oriented Programming can help you. Learn classes, objects, inheritance, polymorphism, encapsulation, and abstraction with practical programming examples.

Also Read: How to Open a JSON File? A Complete Guide on Creating and Reading JSON

Next, let’s understand how you can uninstall global packages with NPM.

Uninstalling Global Packages with NPM Uninstall Command

Just like you can install npm list global packages, you can also uninstall the same with the help of the ‘npm uninstall’ command. It permanently removes the specified package from the global_nodes directory.

The syntax for the same goes as follows,

npm uninstall -g <package-name>

This is not just limited to one single global package. You can uninstall multiple npm list global packages using this syntax. You simply have to add the package names in the command, separated by spaces.

Furthermore, in cases where you wish to uninstall a specific package version from your system, you can do the same by simply specifying the version number in the Command. 

npm uninstall - g <package-name>@<version>

One key point to consider is that when uninstalling npm list global packages, all the dependencies not shared with other installed packages will also be removed. However, if a dependency is shared with another installed package, it will not get removed from the system. 

Example: Imagine you've installed a package globally for a project, but now the project is complete, and you no longer need that package. 

For instance, if you installed nodemon globally for auto-restarting your server but don’t need it anymore, you can easily remove it using the npm uninstall -g command.

npm uninstall -g nodemon

Expected Output:

removed 1 package in 0.005s

The command removes the nodemon package globally from your system. The message removed 1 package in 0.005s indicates that the uninstallation was successful and nodemon has been removed from your global package list.

Verify Uninstallation: To verify that the package has been uninstalled, you can list your globally installed packages again:

npm ls -g --depth=0

If nodemon has been successfully removed, it will no longer appear in the output list.

The npm uninstall -g command is a quick and easy way to remove unnecessary global packages from your system, keeping your development environment clean and efficient. By regularly uninstalling packages you no longer need, you ensure that your global npm package list stays manageable.

Are you a full-stack developer wanting to integrate AI into your workflow? upGrad’s AI-Driven Full-Stack Development bootcamp can help you. You’ll learn how to build AI-powered software using OpenAI, GitHub Copilot, Bolt AI & more.

Also ReadHow to Check NPM Version: A Comprehensive Guide

Now, let’s look at some advanced NPM commands for power users.

Advanced NPM Commands for Power Users

For more control and flexibility in managing your Node.js projects, power users rely on advanced NPM commands. These commands allow you to manage dependencies, scripts, and configurations with precision.

Below is a more comprehensive list of advanced NPM commands, along with examples to help you make the most of them:

Command

Description

Example

npm install <package>@<version> Installs a specific version of a package, useful for testing or when a particular version is required. npm install lodash@4.17.21
npm update <package> Updates a specific package to the latest version, or to a version matching the specified range. npm update express
npm outdated Lists outdated packages in your project along with their current, wanted, and latest versions. npm outdated
npm run <script> Executes a custom script defined in the scripts section of your package.json. npm run start (assuming start is defined in package.json as a script)
npm prune Removes extraneous packages that are not listed in the dependencies or devDependencies of your package.json. npm prune
npm ls <package> Displays the version of a specific package installed in your project, including its dependency tree. npm ls lodash
npm ci Installs dependencies directly from package-lock.json for a clean, reproducible environment. npm ci (ideal for continuous integration environments)
npm cache clean --force Clears the NPM cache, which can resolve issues caused by corrupted cache data. npm cache clean --force
npm audit fix Automatically fixes vulnerabilities found during the audit process. npm audit fix
npm publish Publishes your package to the NPM registry, making it available for others to install. npm publish
npm link Creates a global symlink for a local package, useful for testing a package across multiple projects. npm link <package-name>
npm uninstall <package> Uninstalls a package and removes it from package.json. npm uninstall lodash
npm version <new-version> Bumps the version of your package according to semantic versioning (patch, minor, major). npm version patch (increments the patch version)
npm dedupe Deduplicates dependencies by removing redundant packages in the node_modules folder. npm dedupe
npm shrinkwrap Creates a npm-shrinkwrap.json file, which locks the versions of dependencies for consistent installs. npm shrinkwrap
npm set <key> <value> Sets a configuration option for NPM, useful for customising global or project-specific settings. npm set init.author.name "John Doe"
npm config get <key> Retrieves the value of a specific NPM configuration setting. npm config get registry
npm help <command> Displays detailed help for a specific NPM command. npm help install
npm uninstall --save-dev <package> Uninstalls a development dependency and updates package.json accordingly. npm uninstall --save-dev mocha

These advanced commands provide granular control over package management, dependency handling, and project scripts, enabling developers to streamline workflows and maintain efficiency in larger, more complex Node.js projects.

Also ReadHow to Install Dev Dependencies in npm? Complete Beginner’s Guide

Using NPM can become a lot easier with some strategies. Let’s look at some of the key best practices you can follow.

Best Practices for Managing NPM Global Packages

Managing different npm list packages can seem daunting, especially when dealing with multiple projects that might require different versions of the same package. Therefore knowing when and how to add a package to your project is crucial. 

On that note, here is a detailed guide to effectively managing your npm list packages. 

  • The first rule is to limit the number of global packages. This means you should only add those packages that you absolutely need to use. Cluttering your system or project with too many global packages can result in conflicts and versioning issues. 
  • Secondly, incorporate version managers, such as nvm (node version manager), to effectively manage the different versions of Node.js and npm in your system. This will further enable you to easily switch between different versions without causing any kind of conflict. 
  • You should always keep track of all the installed packages in your system. Document the same to clearly understand how many packages there are and their respective versions.
  • Closely monitor the versions of your package, and update them whenever necessary. This will ensure they are loaded with the latest features and security upgrades. 
  • Harness the power of varied package manager tools such as ‘yarn’ or ‘pnpm,’ especially when dealing with a large volume of global packages. It will improve the overall performance and safeguard your system from potential versioning conflicts.

Also ReadHow to Check NPM Version? Explore Challenges and Tips to Troubleshoot Them

Even when following best practices, there are chances of running into challenges. Here’s how you can troubleshoot common issues with NPM global packages.

Troubleshooting Common Issues with NPM Global Packages

When managing NPM global packages, you may encounter a few common issues such as "package not found" errors, permission problems, conflicts with local packages, or corrupted caches. 

This section will help you troubleshoot these issues, providing clear solutions to ensure smooth package management and avoid disruptions in your development workflow. 

Let’s explore these problems and their fixes in detail.

1. Package Not Found

  • Double-check the package name: One of the most frustrating issues is when you try to install a package, but it can't be found. Ensure that you’ve typed the correct package name. It's easy to misspell or confuse similar names. For example, typing express as express will result in a "package not found" error.
  • Check the NPM registry: Sometimes, the package might be temporarily unavailable, or the version you're looking for could be deprecated. You can verify this by checking the NPM website or using npm info <package-name> to see the package details and confirm its availability.

2. Permission Issues

  • Run with administrator or sudo: If you’re getting permission errors when installing or updating global packages, it’s often due to file access restrictions on your system. Running the command as an administrator (Windows) or using sudo (Linux/macOS) usually resolves this. However, be cautious. Using sudo can sometimes lead to further complications if it inadvertently changes file permissions, so try running as an administrator first if you're on Windows.
  • Avoiding root issues: If possible, avoid running NPM commands with root privileges (sudo) unless absolutely necessary, as it can cause long-term permission issues. Instead, consider fixing file permissions with chown or managing package installations using a version manager like nvm.

3. Conflict with Local Packages

  • Version conflicts: If you’re working on multiple projects, a global package might conflict with a local package that uses a different version. This is common with tools like webpack or babel that often update across different projects. If you face errors related to version mismatches, you can either:
    • Update the local package to match the global one, or
    • Uninstall the global package and use a local version instead to avoid potential versioning conflicts.

4. Corrupt Cache

  • Clearing the cache: A corrupted NPM cache can cause issues like incomplete installs or version mismatches. If you suspect this is the case, clearing the cache with npm cache clean --force can help. It forces NPM to download fresh versions of the packages and ensures you’re working with the most up-to-date files.
  • Real-world example: Imagine you've tried installing a package, but you keep getting strange errors, or the installation is failing repeatedly. Clearing the cache helps eliminate any corrupted data that might be causing the issue, much like clearing your browser’s cache when a website isn't loading properly.

Also ReadHow to Install Specific Version of NPM Package?

Conclusion

Now, let’s look at how upGrad can help you master the usage of NPM.

How Can upGrad Help You Learn NPM and Advanced Programming Concepts?

Knowing how to get a list of globally installed NPM packages is an essential skill for developers managing their JavaScript environment. It helps track installed packages, maintain consistency, and ensure that the right versions are being used across projects. This level of control can improve the efficiency and stability of your development process.

Exploring software engineering courses with upGrad can help you gain practical experience with NPM and other essential tools. Along with the programs covered above, here are some additional courses to start your journey in package management.

Feeling unsure about where to begin with your software career? Connect with upGrad’s expert counselors or visit your nearest upGrad offline centre to explore a learning plan tailored to your goals. Transform your programming journey today with upGrad!

References:
https://zenodo.org/records/14914149

Frequently Asked Questions (FAQs)

1. How do I install NPM on my system?

2. What is the difference between global and local packages in NPM?

3. How do I install a specific version of an NPM package?

4. How can I update an NPM package to the latest version?

5. How do I uninstall an NPM package?

6. What is the NPM registry?

7. What are "devDependencies" in NPM?

8. How can I create a custom NPM script?

9. How can I resolve version conflicts between NPM packages?

10. How can I clear the NPM cache?

11. How can I use NPM to install packages from a specific GitHub repository?

Pavan Vadapalli

900 articles published

Director of Engineering @ upGrad. Motivated to leverage technology to solve problems. Seasoned leader for startups and fast moving orgs. Working on solving problems of scale and long term technology s...

Get Free Consultation

+91

By submitting, I accept the T&C and
Privacy Policy

India’s #1 Tech University

Executive PG Certification in AI-Powered Full Stack Development

77%

seats filled

View Program

Top Resources

Recommended Programs

upGrad

AWS | upGrad KnowledgeHut

AWS Certified Solutions Architect - Associate Training (SAA-C03)

69 Cloud Lab Simulations

Certification

32-Hr Training by Dustin Brimberry

upGrad

Microsoft | upGrad KnowledgeHut

Microsoft Azure Data Engineering Certification

Access Digital Learning Library

Certification

45 Hrs Live Expert-Led Training

upGrad

upGrad KnowledgeHut

Professional Certificate Program in UI/UX Design & Design Thinking

#1 Course for UI/UX Designers

Bootcamp

3 Months