Find unused npm packages in package.json

后端 未结 8 988
孤街浪徒
孤街浪徒 2020-12-12 08:52

Is there a way to determine if you have packages in your package.json file that are no longer needed?

For instance, when trying out a package and later commenting o

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 09:17

    You can use an npm module called depcheck (requires at least version 10 of Node).

    1. Install the module:

      npm install depcheck -g
      
      or
      
      yarn global add depcheck
      
    2. Run it and find the unused dependencies:

      depcheck
      

    The good thing about this approach is that you don't have to remember the find or grep command.

    To run without installing use npx:

    npx depcheck
    

提交回复
热议问题