remove unused dependencies in React remove unused dependencies in React reactjs reactjs

remove unused dependencies in React


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


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


Using depcheck to Track Dependencies

npm install -g depcheck

This installs depcheck globally on your system.

Run the following command inside your folder where you want your dependencies to be checked.

depcheck

Ensure that this folder contains the package.json file, otherwise depcheck will not be able to track your dependencies.

Let suppose you installed the react-bootstrap package and did not import anything from it.

Running depcheck gives the following output:

Unused dependencies* ...* react-bootstrap* ... Missing dependencies* ...  

In general, you can uninstall any npm package or dependency by running the following command:

npm uninstall <package_name>npm uninstall react-bootstrap

npm-uninstall docs