Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list unused node modules/dependencies from your React Project?

Need a solution to remove unused node modules and node modules dependencies from a project.

I have searched internet and found couple of NPM package to do something similar but not exactly my requirement.

Please note, Node modules should be listed/removed if that is neither a dependencies in other node modules nor used in any project code.

Please help

like image 533
sachin kumar Avatar asked Jan 11 '18 15:01

sachin kumar


People also ask

How do I see unused dependencies in React?

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.

How do I find unused dependencies in my project?

npm-check checks for outdated, incorrect, and unused dependencies. To use npm-check from the command line you have to install it. It requires Node >= 0.11. After installing it, it can be used with typing npm-check in the root project directory, where the package.

How do I get rid of unused node modules?

You can use npm-prune to remove extraneous packages. Extraneous packages are packages that are not listed on the parent package's dependencies list. If the --production flag is specified or the NODE_ENV environment variable is set to production, this command will remove the packages specified in your devDependencies.


1 Answers

Perhaps you could use a tool like 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.

Another one is npm-check

Check for outdated, incorrect, and unused dependencies. ... Kindly informs you if a dependency is not being used in your code ...

like image 72
jacobq Avatar answered Sep 22 '22 20:09

jacobq