yarn自动清除

从包依赖里清除并移除不需要的文件。

yarn autoclean [-I/--init] [-F/--force]

autoclean 命令通过从依赖文件中移除不需要的文件和文件夹来释放空间 它减少了你的项目 node_modules 里的文件,在包直接签入到版本控制系统的环境里很有用。

注意:此命令只被用于高级用例。 除非你遇到了 node_modules 里安装的文件数问题,不推荐使用此命令。 这个命令会永久删除在node_modules里的那些会造成包停止工作的文件

autoclean默认是disabled To enable it, manually create a .yarnclean file, or run yarn autoclean --init to create the file with default entries. The .yarnclean file should be added to version control.

When the .yarnclean file exists in a package, autoclean functionality will be enabled. The clean will be performed:

  • After an install
  • After an add
  • If yarn autoclean --force is run

The clean is performed by reading each line of the .yarnclean file and using each as a glob pattern of files to delete.

Options:

-I/--init : Creates the .yarnclean file if it does not exist, and adds the default entries. This file should then be reviewed and edited to customize which files will be cleaned. If the file already exists, it will not be overwritten.

-F/--force : If a .yarnclean file exists, run the clean process. If the file does not exist, do nothing.

示例︰

You decide all YAML and Markdown files in all your dependencies installed in node_modules can be safely deleted. You make a .yarnclean file containing:

*.yaml
*.md

You then run yarn install or yarn autoclean --force. The clean process will delete all *.yaml and *.md files within node_modules/ recursively (including nested transient dependencies).