I know it has been asked before, but depcheck doesn't seem to work for me at all. It gives me a ton of false alerts aparts from having to configure it for "config-only" libs like babel, eslint etc.
What is your approach if you get a task like it? Is there any best practice you could recommend me?
Thank you!
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.
json. To identify the unused package, just run npx depcheck in the project root directory. Next step is to uninstall the npm packages using npm uninstall command. The post Remove unused npm modules from package.
To remove a dev dependency, you need to attach the -D or --save-dev flag to the npm uninstall, and then specify the name of the package. You must run the command in the directory (folder) where the dependency is located.
The answer is npm-check.
npm i -g npm-check
Then enter the directory of you project and run the tool
cd my-app
npm-check
some-package 😕 NOTUSED?
To remove this package: npm uninstall --save some-package
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With