快速删除 node_modules 目录的集中方法

要快速删除 node_modules 目录,可以使用以下几种方法:

方法 1: 使用 rimraf
如果你在 Windows 上或者想要一个跨平台的解决方案,可以使用 rimraf 这个工具,它是 Node.js 版本的 rm -rf。

安装 rimraf:

npm install -g rimraf

然后在终端中执行:

rimraf node_modules

方法 2: 使用 npx 运行 rimraf
如果你不想全局安装 rimraf,也可以使用 npx 来运行:

npx rimraf node_modules

方法 3: 使用 del 命令(Windows)
在 Windows 的命令提示符(CMD)中,使用 del 命令删除:

rd /s /q node_modules

rd 是删除目录命令
/s 删除目录及其内容
/q 静默模式,不需要确认
这些方法可以根据你的操作系统来选择,快速有效地删除 node_modules 目录。

PS D:\酒店预订\xm-hotel-manager> cd vue PS D:\酒店预订\xm-hotel-manager\vue> npm i npm error code EPERM npm error syscall open npm error path D:\ns\node_cache\_cacache\index-v5\ae\cb\7c962421f0da92fc4dbb8f92fe10d9492fff205c3578e6c892f0e881c0e2 npm error errno -4048 npm error Error: EPERM: operation not permitted, open 'D:\ns\node_cache\_cacache\index-v5\ae\cb\7c962421f0da92fc4dbb8f92fe10d9492fff205c3578e6c892f0e881c0e2' npm error at async open (node:internal/fs/promises:638:25) npm error at async writeFile (node:internal/fs/promises:1212:14) npm error at async Object.insert (D:\ns\node_modules\npm\node_modules\cacache\lib\entry-index.js:134:5) npm error at async CacheEntry.store (D:\ns\node_modules\npm\node_modules\make-fetch-happen\lib\cache\entry.js:308:7) npm error at async fetch (D:\ns\node_modules\npm\node_modules\make-fetch-happen\lib\fetch.js:98:7) npm error at async RegistryFetcher.packument (D:\ns\node_modules\npm\node_modules\pacote\lib\registry.js:90:19) npm error at async RegistryFetcher.manifest (D:\ns\node_modules\npm\node_modules\pacote\lib\registry.js:128:23) npm error at async #fetchManifest (D:\ns\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1202:20) npm error at async #nodeFromEdge (D:\ns\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1040:19) npm error at async #buildDepStep (D:\ns\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:904:11) { npm error errno: -4048, npm error code: 'EPERM', npm error syscall: 'open', npm error path: 'D:\\ns\\node_cache\\_cacache\\index-v5\\ae\\cb\\7c962421f0da92fc4dbb8f92fe10d9492fff205c3578e6c892f0e881c0e2', npm error requiredBy: '.' npm error } npm error npm error The operation was rejected by your operating system. npm error It's possible that the file was already in use (by a text editor or antivirus), npm error or that you lack permissions to access it. npm error npm error If you believe this might be a permissions issue, please double-check the npm error permissions of the file and its containing directories, or try running npm error the command again as root/Administrator. npm error Log files were not written due to an error writing to the directory: D:\ns\node_cache\_logs npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal 在idea中
最新发布
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值