Reputation: 642
How do I detect unused dependencies in a React project? I know there are npm packages that can do it, but they only work with normal js projects, not with Reacts jsx file. Is there a similar package that works with React?
Upvotes: 25
Views: 42723
Reputation: 419
npm install -g depcheck
This installs depcheck globally on your system.
depcheck
Ensure that this folder contains the package.json file, otherwise depcheck will not be able to track your dependencies.
Running depcheck
gives the following output:
Unused dependencies
* ...
* react-bootstrap
* ...
Missing dependencies
* ...
npm uninstall <package_name>
npm uninstall react-bootstrap
Upvotes: 21
Reputation: 856
try about depcheck,Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and which dependencies are missing from package.json.
NOTE: Depcheck requires installed node version > NODE 10
Upvotes: 7
Reputation: 217
you can use npm-check for finding outdated, incorrect, and unused dependencies in your project. After installing it you have to only run npm-check command in your terminal and it will list you status of your dependencies in your project
Upvotes: 8