如何删除所有的node_modules文件夹内容

I had to transfer a folder full of old projects to a new computer, and after trying to compress it, I realized the size was 8GB. A bit too much for some coding projects that only contain text files.

我不得不将一个充满旧项目的文件夹转移到新计算机上,并尝试对其进行压缩后,我意识到它的大小为8GB。 对于仅包含文本文件的某些编码项目来说,有点太多了。

They were all JavaScript projects, and every project contained a node_modules folder.

它们都是JavaScript项目,每个项目都包含一个node_modules文件夹。

The folder is totally unnecessary because I can always run npm install in a project to re-generate it, and most of those projects I had in that folder were old things I’ll never use ever again.

该文件夹是完全不必要的,因为我总是可以在一个项目中运行npm install来重新生成它,并且我在该文件夹中拥有的大多数项目都是旧的东西,我将不再使用。

So I decided to remove all the node_modules folders, but they were too many. So I went into the parent folder, which I called dev, and I ran this command in the ZSH terminal, the shell that comes by default with macOS Catalina:

因此,我决定删除所有的node_modules文件夹,但是它们太多了。 因此,我进入了名为dev的父文件夹,并在ZSH终端(macOS Catalina默认提供的shell)中运行了此命令:

find . -name "node_modules" -type d -prune -exec rm -rf '{}’ +

This reduced the size of my folder from 8GB to 2GB. Pretty nice for a one-line command.

这将我的文件夹大小从8GB减小到2GB。 单行命令非常好。

I found this command on this blog, there you can find more explanation on the command details.

在此博客上找到了此命令,您可以在其中找到有关命令详细信息的更多说明。

翻译自: https://flaviocopes.com/how-to-bulk-remove-node-modules/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值