当我们在进行初始化一个 nuxt 项目时,执行: npx nuxi@latest init <project-name>
这时候会出现如下报错
Error: Failed to download template from registry: Failed to download https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json: TypeError: fetch failed
原因: 某个数据源被墙了
解决方法
- 以 管理员身份 打开 cmd
- 进入
hosts所在目录,默认在C:\Windows\System32\drivers\etc下
cd C:\Windows\System32\drivers\etc
- 用记事本打开
hosts文件
notepad hosts
- 在最下面添加
185.199.108.133 raw.githubusercontent.com
- 保存退出就可以了