Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • NodeJS Tutorial
  • NodeJS Exercises
  • NodeJS Assert
  • NodeJS Buffer
  • NodeJS Console
  • NodeJS Crypto
  • NodeJS DNS
  • NodeJS File System
  • NodeJS Globals
  • NodeJS HTTP
  • NodeJS HTTP2
  • NodeJS OS
  • NodeJS Path
  • NodeJS Process
  • NodeJS Query String
  • NodeJS Stream
  • NodeJS String Decoder
  • NodeJS Timers
  • NodeJS URL
  • NodeJS Interview Questions
  • NodeJS Questions
  • Web Technology
Open In App
Next Article:
How to Find the Version of an Installed NPM Package in Node.js ?
Next article icon

How To Get a List of Globally Installed NPM Packages in NPM?

Last Updated : 15 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

To get a list of globally installed NPM packages, there are several methods you can use depending on the level of detail and format you need. Below, we’ll cover two main approaches that utilize different commands to retrieve this information: npm list and npm ls.

Table of Content

  • Approach 1: Using 'npm list' command:
  • Approach 2: Using 'npm ls' command

Approach 1: Using 'npm list' command:

To get a list of globally installed npm packages, we can use npm list command in our terminal or command prompt. The npm list command is used to list installed npm packages.

  • -g flag indicates that you want to list globally installed packages.
  • --depth=0 option specifies the depth of the dependency tree to display. Setting it to 0 ensures that only the top-level packages are listed without their dependencies.

Syntax:

npm list -g --depth=0

Output:

grghthh
Get a List of Globally Installed NPM Packages in npm

This will show the name and version of each globally installed package. The tree-like structure makes it easy to identify the packages you have installed globally.

Approach 2: Using 'npm ls' command

Another approach to list globally installed packages is by using the npm ls command. This command works similarly to npm list but can provide a cleaner, parseable output, which is useful when you need to process the results programmatically or store them in a file.

  • -g flag indicates that you want to list globally installed packages.
  • --depth=1 option limits the depth of the dependency tree. In this case, --depth=1 limits the output to only the top-level packages and their direct dependencies.

Syntax:

npm ls -g --depth=1

Output

Screenshot-2024-03-13-021336
displaying top-level packages along with their immediate dependencies

This output shows the absolute paths to the globally installed packages, which is particularly useful for scripting or saving the list to a file for later review.

Conclusion

Both npm list and npm ls commands are powerful tools for managing globally installed NPM packages.

  • Use npm list when you want a more detailed, tree-like view of installed packages.
  • Use npm ls --parseable when you need a cleaner, simpler format, particularly for scripting or storing the list in a file.

These commands make it easy to view, update, or uninstall global packages, helping you manage your Node.js development environment more efficiently.


Next Article
How to Find the Version of an Installed NPM Package in Node.js ?
author
bishalpaul34
Improve
Article Tags :
  • Web Technologies
  • Node.js
  • Node-npm

Similar Reads

  • How to list npm user-installed packages in Node.js?
    What is Node.js? Node.js is an open source and cross-platform runtime environment for executing JavaScript code outside of a browser. Click here for more. What is npm? Here, "npm" stands for "Node Package Manager" which is the package manager for Node.js and serves as a command-line utility for inte
    2 min read
  • How to Find the Version of an Installed NPM Package in Node.js ?
    NPM is the default package manager for Node.js. NPM manages both internal and external packages or modules used in various Node.js applications. The default packages in NPM may not fulfil all the needs of a developer, so we often require external packages. These can be installed either locally in a
    2 min read
  • How to Install GIT by NPM Packages?
    Git is a library for git written in Node.js which allows for the manipulation of git repositories by the Node.js application. Git (npm), not to be confused with GIT, the version control software is a Node.js port of the now-defunct Git project. It is fairly synchronous as-is, and it allows the devel
    2 min read
  • How to Force an NPM Package to Install?
    Forcing an NPM package to install can be necessary in cases where the dependencies of a package are in conflict or when you need to override existing constraints or force the installation of a specific version. Forcing an NPM package to install refers to using specific commands to bypass version con
    3 min read
  • How to Install an NPM Package Directly from GitHub ?
    Installing npm packages directly from GitHub can be incredibly useful, especially when you need to use a specific version or branch of a package that may not yet be published to the npm registry. This approach allows developers to take advantage of the latest features, bug fixes, or specific package
    2 min read
  • How To List Installed Python Packages
    Working on Python projects may require you to list the installed Python packages in order to manage dependencies, check for updates, or share project requirements with others. In this post, we'll look at numerous techniques for listing the Python packages that are installed on your system. List Inst
    5 min read
  • How to Find the Version of Installed NPM Package?
    Knowing the version of NPM installed on your system is important especially when working with specific versions of Node JS or when troubleshooting issues. This article provides instructions to check the version of NPM installed on your system. Prerequisites:Node JS Command Line InterfaceSteps To Fin
    1 min read
  • Axios npm - How to Install Axios npm in Terminal?
    Axios is a popular JavaScript library for making HTTP requests in web applications. It simplifies the process of sending asynchronous requests and handling responses. It is commonly used with Node.js and in browser-based projects and can be installed via NPM (Node Package Manager). In this article,
    2 min read
  • How to remove all Global Modules in Node.js ?
    Node.js is an open-source and cross-platform runtime environment for executing JavaScript code outside of a browser. You need to remember that Node.js is not a framework and it’s not a programming language. Most of the people are confused and understand it’s a framework or a programming language. We
    2 min read
  • How to Download and Install Node.js and NPM
    NodeJS and NPM (Node Package Manager) are essential tools for modern web development. NodeJS is the runtime environment for JavaScript that allows you to run JavaScript outside the browser, while NPM is the package manager that helps manage libraries and code packages in your projects. To run a Node
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences