【Mac】各种环境问题解决

1. npm相关

1.1 time out类型

  1. 运行 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

这时 问题成功解决,项目成功运行。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值