Nuxt出现Error: Failed to download template from registry
在尝试初始化Nuxt项目时,遇到无法下载模板文件https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json
的问题。尽管本地浏览器能访问该URL,但命令行工具提示下载失败,查资料发现,这是由于DNS解析失败及HTTPS请求通过HTTP代理转发错误(TypeError: fetch failed
)。
解决办法:
在本地进行dns配置,让本地可以直接访问到这个域名。把 C:\Windows\System32\drivers\etc中的host文件末尾添加
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
C:\Windows\System32\drivers\etc文件夹下是不允许修改的,建议考出来修改,把源文件备份后删除,再把修改后文件加入到这个文件夹下。
参考文章:https://juejin.cn/post/7357292176944463899