最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to list unused node modulesdependencies from your React Project? - Stack Overflow

programmeradmin5浏览0评论

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

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

Share Improve this question edited Jan 12, 2018 at 10:23 Iliya Frolov 433 bronze badges asked Jan 11, 2018 at 15:42 sachin kumarsachin kumar 1591 gold badge1 silver badge10 bronze badges 3
  • Are you using webpack?, if so, you can use tree shaking webpack.js/guides/tree-shaking – Cesar Contreras Commented Jan 11, 2018 at 16:03
  • we are not using webpack. Also treeshaking will not remove modules which are not used in my code. – sachin kumar Commented Jan 12, 2018 at 10:26
  • This question is asked in a more general way here. – Marco Lackovic Commented Feb 19, 2019 at 9:54
Add a ment  | 

3 Answers 3

Reset to default 8

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 ...

Run npm prune to unbuild modules not listed in package.json.

From npm help prune:

This mand removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed.

Extraneous packages are packages that are not listed on the parent package's dependencies list.

If the --production flag is specified, this mand will remove the packages specified in your devDependencies.

From : npm mand to uninstall unused packages in Node.js

I've recently used npm-check

Check for outdated, incorrect, and unused dependencies.

After installing just run the mand in terminal:

$ npm-check

发布评论

评论列表(0)

  1. 暂无评论