按照官方文档的说明通过以下命令创建Nuxt3项目:
pnpm dlx nuxi@latest init nuxt-demo
然而,在运行该命令后,可能会遇到以下报错信息:
Error: Failed to download template from registry: Failed to download https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json: TypeError: fetch failed
即使按照他人的方法在host
文件添加185.199.108.133 raw.githubusercontent.com
,通过浏览器访问链接https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json
仍无法访问。
经过观察,我们发现该链接返回的是一个JSON内容,示例如下:
{
"name": "v3",
"defaultDir": "nuxt-app",
"url": "https://v3.nuxtjs.org",
"tar": "https://codeload.github.com/nuxt/starter/tar.gz/refs/heads/v3"
}
结合报错信息,我们可以推断出问题可能出现在下载Nuxt3项目模板的过程中。既然无法通过命令安装,我们可以尝试手动下载模板。
你可以手动访问以下链接进行下载:https://codeload.github.com/nuxt/starter/tar.gz/refs/heads/v3
然后将下载好的压缩包解压到你的项目目录中,并执行以下命令:
pnpm install
通过上述步骤,你应该能够解决这个问题了