如何快速删除node_modules依赖文件

421 阅读1分钟

方法一:使用 git bash

注:在 linux 或 mac 下,也可以使用rm -rf node_modules来快速删除文件夹。

rm -rf node_modules

image.png

方法二:使用 powershell

在项目录下快速打开PowerShell的方法: 按住 Shift 键,‌然后点击鼠标右键,‌选择 “在此处打开Powershell窗口”。‌

rd -r node_modules

image.png

image.png

方法三:使用cmd

rd /s /q node_modules 或 rmdir /s /q node_modules

image.png

方法四:使用 powershell

del node_modules 或 del ./node_modules 或 rm -force ./node_modules

image.png

方法五:安装 rimraf

注:rimraf 删除 pnpm 安装的依赖有时候会报错

npm install rimraf -g
rimraf node_modules

方法六:通常删除依赖后,需要重新安装依赖。建议在安装前,删除package-lock.json以及清理缓存

npm cache clean -f
rimraf package-lock.json

删除node_modules依赖文件很慢?其实三秒就能删除了