nuxt 初始化报错Error: Failed to download template from registry: Failed to download

944 阅读1分钟

当我们在进行初始化一个 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

nuxtInitErr.png

原因: 某个数据源被墙了

解决方法

  1. 管理员身份 打开 cmd
  2. 进入hosts所在目录,默认在 C:\Windows\System32\drivers\etc
cd C:\Windows\System32\drivers\etc
  1. 用记事本打开 hosts文件
notepad hosts
  1. 在最下面添加
185.199.108.133 raw.githubusercontent.com
  1. 保存退出就可以了