Find unused npm packages in package.json
There is also a package called npm-check
:
npm-check
Check for outdated, incorrect, and unused dependencies.
It is quite powerful and actively developed. One of it's features it checking for unused dependencies - for this part it uses the depcheck
module mentioned in the other answer.
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