因为这几天一直在写项目,然后刚开始进行部署的时候遇到了一些问题,比如node版本问题,和npm缓存问题...还有element plus资源更新使用等问题,现在和大家分享一下我是如何解决的,希望对大家以后写项目的时候会有写帮助
当我们进行多人合作的时候,我们需要不停的合并我们的代码,并且再获得一个新代码的编写,这个时候我们就需要进行一个新的npm缓存,因为node_module文件是在我们本地的,不会从远程拉过来,所以我们需要重新下载npm缓存
类似这种情况就是依赖缓存没有下载完全 有关node_module
但是每次在我的本地文件夹终端每次进行进行npm缓存更新的时候,就会报这种错误。
PS D:\system-manager\study-group-manager-web> npm i
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: stylelint-config-recommended@15.0.0
npm warn Found: stylelint@14.16.1
npm warn node_modules/stylelint
npm warn dev stylelint@"^14.13.0" from the root project
npm warn 6 more (stylelint-config-html, stylelint-config-prettier, ...)
.........................(省略)
npm warn Could not resolve dependency:
npm warn peer stylelint@"^16.13.0" from the root project
npm error code ETIMEDOUT
npm error syscall connect
npm error errno ETIMEDOUT
npm error network request to https://registry.npmmirror.com/stylelint failed, reason: connect ETIMEDOUT 2408:8719:3000:5:3::3fa:443
npm error network This is a problem related to network connectivity.
npm error network In most cases you are behind a proxy or have bad network settings.
npm error network
npm error network If you are behind a proxy, please make sure that the
npm error network 'proxy' config is set properly. See: 'npm help config'
npm error Log files were not written due to an error writing to the directory: D:\mysoftware\node_cache\_logs
npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
可能出现的问题:
1. **权限不足**:当前用户对目标目录没有写入权限。
2. **文件被占用**:目录或文件可能被其他程序(如文本编辑器、IDE、杀毒软件)锁定。
3. **缓存问题**:npm的缓存目录可能存在损坏或权限问题。
4. **版本问题**...等
之前我遇到这种报错的时候,不知道怎么改,就一直问AI如何解决这种问题,但是几番试下来还是没有解决,虽然AI给了我很多解决方案,但是那这种我使用下来还是没能解决我的问题,反而有点越走越偏的感觉,下面是我的解决方法:
右键点击电脑->然后点击终端管理员
通过cd进入到自己的项目文件夹
配置淘宝镜像:npm config set registry https://registry.npmmirror.com/
清除缓存:
# 1. 清理缓存和旧依赖
npm cache clean --force
rm -rf node_modules package-lock.json
这样就安装成功了