sh 删除dep文件夹:`node_modules`,`bower_components`

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 删除dep文件夹:`node_modules`,`bower_components`相关的知识,希望对你有一定的参考价值。

# Delete all Dependency Folders

Removes folders like `node_modules` & `bower_components`.

Install by placing that in a `.bash_profile` or similar.

This would run it in current directory and recurse on down:

```bash
delete-all-dep-folders
```

This would run it on the folder you point to:

```bash
delete-all-dep-folders path/to/folder/
```
# Delete dep folders: `node_modules`, `bower_components`
# @param $1 [.] Which folder to recursively look in; defaults to cwd (`.`).
delete-all-dep-folders() {
  # `-prune` prevents building up lists of `node_modules` inside `node_modules`
  find ${1:-.} -type d -name "node_modules" -prune -exec rm -rf '{}' \; -exec echo 'Deleted {}' \;
  find ${1:-.} -type d -name "bower_components" -prune -exec rm -rf '{}' \; -exec echo 'Deleted {}' \;
  
  # This one is a little spooky as `vendor/` folders aren't exclusive to Composer. 
  # @todo Test if `composer.json` is next to `vendor/` before deleting.
  # find ${1:-.} -type d -name "vendor" -prune -exec rm -rf '{}' \; -exec echo 'Deleted {}' \;
}

以上是关于sh 删除dep文件夹:`node_modules`,`bower_components`的主要内容,如果未能解决你的问题,请参考以下文章

sh 递归删除目录中的所有node_modules文件夹

sh 在Mac上递归删除所有node_modules文件夹

sh 以递归方式删除node_modules

sh 删除所有node_modules和bower_components目录

修改 make distclean 以便删除 .deps 或 *~ 备份文件

Windows中目录及文件路径太长无法删除的解决方法