一、问题描述
使用nuxt3创建项目:
npx nuxi init nuxt3-app
提示如下报错:
ERROR Error: Failed to download template from registry: Failed to download https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json: TypeError: fetch failed
二、解决方案
该问题与之前的文章《Error: pngquant failed to build, make sure that libpng-dev is installed》类似,解决方案可以参考该文章后面提到的方法。
在此,简要说明一下操作流程:
①前往https://www.ipaddress.com/ip-lookup查找到raw.githubusercontent.com
的IP:
②找到本机hosts文件,一般路径地址为:C:\Windows\System32\drivers\etc\hosts
打开hosts修改,将上面对应的IP和域名放到hosts文件末尾
即添加:
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.108.133 raw.githubusercontent.com
2606:50c0:8001::154 raw.githubusercontent.com
2606:50c0:8002::154 raw.githubusercontent.com
2606:50c0:8003::154 raw.githubusercontent.com
2606:50c0:8000::154 raw.githubusercontent.com
③添加完此映射关系之后,打开CMD,输入 ipconfig/flushdns 刷新下本地的DNS缓存。
④重新运行npx nuxi init nuxt3-app
命令: