How to get list of globally installed npm packages
To get the list of npm packages installed globally in your computer, we have to use -g flag along with npm list command.
In this article, we will learn how to get the list of globally installed npm packages on our computer.
While working with npm package we sometimes have to install some packages globally using -g or -global flag with npm install.
However, with times, we may no longer use some global packages and want to remove them. To do that first we have to find out about the list of global npm packages installed on our computer.
To get the list of all the globally installed npm packages, we can use the command npm list -g. However, depending on the node version, we can use other flags to get the package name and its dependencies.
For node 6 and below
npm list -g --depth 0
npm : stands for the node package manager
list -g : list all the npm packages installed globally
--depth 0 : this flag is used to hide each installed package's dependencies. To show use --depth 1.
For node 7 and above
npm list -g // or npm list -global
In node 7 and above, you don't have to use the --depth 0 flag because npm list command already hides the dependencies of the installed npm packages by default.
However, if you want to display all the dependencies of the installed global packages, you can run add --all config flag or just run
npm list -g --all
You can also use --depth 1 in node 7 too.
Related Topics:
Related Posts
Solve npm ERR! ENOENT - No Such File or Directory Error
Learn what causes the npm ERR! ENOENT error, steps to troubleshoot it, and how to fix the no such file or directory issue when running npm start or npm install commands on your Node.js project.
How to Clear Cache in NPM?
In this tutorial we will learn how to clean or remove npm cache from Windows, linux and Mac using npm cache clean command.
How to Downgrade an Installed npm Package
Learn how to downgrade npm packages for compatibility issues, bug fixes, new features, or personal preference. Follow step-by-step guide for a easy downgrade process.
(Fixed) npm ERR! missing script: start error
This article is about how to fix npm err! missing script start error in nodejs application.
