今天查看了项目的node_modules文件,有2.78G,好家伙,占用空间有点大,然后就删掉了node_modules和package-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文件也没有那么大了,恢复到了几百兆

相关链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: