使用命令行从指定路径递归删除node_modules文件夹 [英] Delete node_modules folder recursively from a specified path using command line
问题描述
我在本地目录中保存了多个npm项目.现在,我想在没有node_modules
文件夹的情况下备份我的项目,因为它占用了大量空间,并且可以随时使用npm install
进行检索.
I have multiple npm projects saved in a local directory. Now I want to take backup of my projects without the node_modules
folder, as it is taking a lot of space and can also be retrieved any time using npm install
.
因此,我需要一个解决方案,以使用命令行界面从指定路径中递归删除所有node_modules文件夹. 任何建议/帮助都是高度赞赏的.
So, I need a solution to delete all node_modules folders recursively from a specified path using the command line interface. Any suggestions/ help is highly appreciable.
推荐答案
打印出要删除的目录列表:
Print out a list of directories to be deleted:
find . -name 'node_modules' -type d -prune
从当前工作目录中删除目录:
Delete directories from the current working directory:
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
或者,您可以使用垃圾(brew install trash
)进行分阶段删除:
Alternatively you can use trash (brew install trash
) for staged deletion:
find . -name node_modules -type d -prune -exec trash {} +
这篇关于使用命令行从指定路径递归删除node_modules文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!