6

I am trying to find a way to check if a particular package is installed in my project through terminal. Is there a command for that? Something like npm check redux.

Eduard
  • 8,437
  • 10
  • 42
  • 64

2 Answers2

13

you can check easily for that. this will describe all the package installed globally

npm list -g --depth=0

this will describe all the package installed locally on your project.

npm list --depth=0

if you want to check for a particular module is installed or not. Please use the following command in project folder. if installed, will display package name and version installed. if not installed, then will not display anything.

npm list --depth=0 | grep <module_name>

for more detail information please see this link. Click here for more info of your question

--depth=0 is necessary so that your terminal isn't flooded with package dependencies. if you are not use this option, you will see the all the dependencies tree.

Lead Developer
  • 1,146
  • 10
  • 26
  • Thank you! This answers the question, but now, since I added this command to package.json scripts, I am having another issue. If you could help, would be great :) https://stackoverflow.com/questions/48006553/how-to-define-a-custom-console-log-if-a-script-in-package-json-throws-an-error – Eduard Dec 28 '17 at 11:44
  • 1
    For me (on linux) `npm list -g --depth=0` gives me npm itself. The depth for packages would be 1. – blindguy Jan 04 '19 at 23:43
  • @blindguy thanks for your testing. I didn't try this in linux. your comment will help visitors of this answer. – Lead Developer Oct 24 '19 at 18:27
4

If you are searching for specific package installed in your project, you can use one of the commands below based on what kind of terminal you use. If you are using Unix shell based terminal, you can use:

npm list --depth=0 | grep <module_name> 

or if you're using windows terminal or power shell, you can use:

npm list --depth=0 | findstr <module_name>

findstr is a similar command like grep in unix shell.

Yodi S.
  • 106
  • 1
  • 5