创建项目:
npx nuxi@latest init nuxt3-project
**报错:**Error: Failed to download template from registry: Failed to download https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json: TypeError: fetch failed
解决方法一:
访问这个地址:https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json
// 20241021154402
// https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json
{
"name": "v3",
"defaultDir": "nuxt-app",
"url": "https://nuxt.com",
"tar": "https://codeload.github.com/nuxt/starter/tar.gz/refs/heads/v3"
}
然后通过 https://codeload.github.com/nuxt/starter/tar.gz/refs/heads/v3
下载项目初始文件,starter-3.tar.gz
安装依赖:pnpm install
运行项目:pnpm dev
解决方法二:
找到本地的 hosts
文件,C:\Windows\System32\drivers\etc
然后在系统的hosts文件添加如下配置:
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
2606:50c0:8000::154 raw.githubusercontent.com
2606:50c0:8001::154 raw.githubusercontent.com
2606:50c0:8002::154 raw.githubusercontent.com
2606:50c0:8003::154 raw.githubusercontent.com