Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm ls matching a pattern?

Tags:

node.js

npm

redux

I just installed a couple of packages to start working with Redux:

npm install --no-optional --save-dev redux-devtools
npm install --no-optional --save react-redux

Then I wanted to make sure everything is installed, so I checked with npm ls:

$ npm ls react redux
MyProject@ /home/me/projects/myproject
├── [email protected] 
└── [email protected] 

Yeah, they are here!

However, I wonder if there is a way to check all the packages starting with re. Both of these commands:

npm ls re*
npm ls re

Returned the same error:

MyProject@ /home/me/projects/myproject
└── (empty)

npm ERR! code 1

I thought npm search could make it, but as I understand it looks for available packages, not only the ones that you have installed in your machine.

$ npm search re*
NAME             DESCRIPTION                                           AUTHOR   
requirements-txt requirements-txt - generate requirements.txt (python… =russiani

So: is there a way with npm ls to provide a pattern to check the packages that are installed and match it?

like image 325
fedorqui 'SO stop harming' Avatar asked Apr 15 '26 12:04

fedorqui 'SO stop harming'


1 Answers

How about piping to grep?

$ npm ls | grep 'lod.*'
   └── [email protected]
like image 198
slezica Avatar answered Apr 18 '26 02:04

slezica



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!