node_modules文件过大,删除之后再次安装报error -4048

今天查看了项目的node_modules文件,有2.78G,好家伙,占用空间有点大,然后就删掉了node_modulespackage-lock.json文件,重新执行npm install,然后就报错了,之前记得有这样做过,也没有报错呀,离大谱

npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'rename',
npm ERR!     dest: 'D:\\XXXXX\project\\oss\\node_modules\\compression-webpack-plugin\\package.json'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   path: 'D:\\XXXXX\\project\\oss\\node_modules\\compression-webpack-plugin\\package.json.3700355834',
npm ERR!   dest: 'D:\\XXXXX\\project\\oss\\node_modules\\compression-webpack-plugin\\package.json',
npm ERR!   parent: 'oss'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Program Files\nodejs\node_cache\_logs\2023-01-12T05_18_52_549Z-debug.log

刚开始以为是自己node.js环境变量没配置好,重新检查了一遍,少了这些配置
在这里插入图片描述
在这里插入图片描述
然后重新下载依赖包,发现还是不行,网上解决方案挺多,但总有不适合自己项目的

使用npm cache verify清除npm缓存
重新下载依赖包,依旧报错

清除缓存:
Cache verified and compressed (C:\Program Files\nodejs\node_cache\_cacache):
Content verified: 4661 (496839341 bytes)
Index entries: 7125
Finished in 4.26s

接着再试试别的方法,找到了一个播客是下载的时候后面加上了淘宝镜像

命令:npm install --registry=https://registry.npm.taobao.org

注意:每次试之前把失败的node_modules和package-lock.json文件删掉,不然还是会报错的

完美解决,虽然不知道前面的检查有没有影响,但好歹项目可以正常运行,node_moudels文件也没有那么大了,恢复到了几百兆

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值