truffle unbox metacoin出现read ECONNRESET、ETIMEOUT、getaddrinfo ENOENT raw.githubusercontent.com问题

环境

windows 10
Truffle v5.4.15
Node v16.13.0

问题

在学习如何初始化truffle项目的时候遇到了以下问题:

//问题一:
PS D:\software\Truffle-project\MetaCoin> truffle unbox metacoin

Starting unbox...
=================

√ Preparing to download box
× Downloading
Unbox failed!
× Downloading
Unbox failed!
Error: getaddrinfo ENOENT raw.githubusercontent.com
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
Truffle v5.4.15 (core: 5.4.15)
Node v16.13.0
//问题二:
D:\software\Truffle-project\MetaCoin>truffle unbox metacoin

Starting unbox...
=================

√ Preparing to download box
× Downloading
Unbox failed!
× Downloading
Unbox failed!
Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20)
Truffle v5.4.15 (core: 5.4.15)
Node v16.13.0
//问题三:
D:\software\Truffle-project\MetaCoin>truffle unbox metacoin

Starting unbox...
=================

√ Preparing to download box
× Downloading
Unbox failed!
× Downloading
Unbox failed!
RequestError: connect ETIMEDOUT 192.30.255.112:443
    at ClientRequest.<anonymous> ...
Truffle v5.4.15 (core: 5.4.15)
Node v16.13.0

原因

都是网络造成的,导致访问不到境外的域名服务器,需要在本地的hosts文件中添加gitbub相关域名。

解决办法

找到hosts(所在目录:C:\windows\System32\drivers\etc\hosts),在其中添加下面的内容:

# GitHub Start

192.30.255.112 gist.github.com

192.30.255.112 github.com

192.30.255.112 www.github.com

151.101.56.133 avatars0.githubusercontent.com

151.101.56.133 avatars1.githubusercontent.com

151.101.56.133 avatars2.githubusercontent.com

151.101.56.133 avatars3.githubusercontent.com

151.101.56.133 avatars4.githubusercontent.com

151.101.56.133 avatars5.githubusercontent.com

151.101.56.133 avatars6.githubusercontent.com

151.101.56.133 avatars7.githubusercontent.com

151.101.56.133 avatars8.githubusercontent.com

151.101.56.133 camo.githubusercontent.com

151.101.56.133 cloud.githubusercontent.com

151.101.56.133 gist.githubusercontent.com

151.101.56.133 marketplace-screenshots.githubusercontent.com

151.101.56.133 raw.githubusercontent.com

151.101.56.133 repository-images.githubusercontent.com

151.101.56.133 user-images.githubusercontent.com

# GitHub End

重新运行tuffle unbox metacoin 就可以了

猜你喜欢

转载自blog.csdn.net/weixin_46353030/article/details/121175878