You can use an npm module called depcheck (requires at least version 10 of Node).
-
Install the module:
npm install depcheck -g or yarn global add depcheck
-
Run it and find the unused dependencies:
depcheck
The good thing about this approach is that you don’t have to remember the find
or grep
command.
To run without installing use npx
:
npx depcheck