1. npm相关
1.1 time out类型
- 运行 npm install时出现如下错误:
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network Invalid response body while trying to fetch https://registry.npmmirror.com/gatsby-core-utils: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/monk/.npm/_logs/2022-07-01T06_40_05_501Z-debug-0.log
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bXXKfiLl-1656661707240)(…/img/bug-1.1.png)]
这里可以看到是gatsby-core-utils超时,所以我们单独下载这个包
运行如下命令:
npm install gatsby-core-utils
这时出现新的错误,这个错误的思路参考了这篇链接
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @jest/test-utils@^26.6.2.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/monk/.npm/_logs/2022-07-01T07_05_36_243Z-debug-0.log
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nCQRircY-1656661707241)(…/img/bug-1.2.png)]
这里可以看到, @jest/test-utils包版本没有,因此我们查看一下
npm view @jest/test-utils
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ExsNkElV-1656661707241)(…/img/bug-1.3.png)]
然后手动安装即可
npm install https://registry.npmmirror.com/@jest/test-utils/-/test-utils-0.0.0.tgz
正常情况下遇到此类问题的步骤到这里就是可以成功解决了的,但是这个包因为是之前瞎捣鼓(感觉是这个包的问题) 导致现在不管安装什么都会报这个错,所以需要对本地缓存进行一次清理
# 先把node_modules删除
npm cache clean --force
npm install --force
这时 问题成功解决,项目成功运行。