How to remove unused npm modules
In this post, we will see how to find the unused npm packages.
Installing the package
To find the unused npm packages, we need to install an npm module
Run the below command to install depcheck
npm install -g depcheck
If you use yarn, run below
yarn add global depcheck
Now go to the root directory of your project and run the below command
depcheck
The above command prints all the unused npm packages in your project
Unused dependencies
* date-fns
You can uninstall all the unused packages like below
npm uninstall -g <package-name>
or
yarn remove <package-name>