这个错误通常是由于网络连接问题导致的
npx nuxi init first-nuxt-app
报错:
ERROR Error: Failed to download template from registry: Failed to download https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json: TypeError: fetch failed
cmd 打开控制台
ping raw.githubusercontent.com
Ping 请求找不到主机 raw.githubusercontent.com。请检查该名称,然后重试。
找到 C:\Windows\System32\drivers\etc\hosts
这个文件使用记事本打开 在最后添加
185.199.108.133 raw.githubusercontent.com
在去ping一下
ping raw.githubusercontent.com
正在 Ping raw.githubusercontent.com [185.199.108.133] 具有 32 字节的数据:
来自 185.199.108.133 的回复: 字节=32 时间=227ms TTL=49
来自 185.199.108.133 的回复: 字节=32 时间=228ms TTL=49
来自 185.199.108.133 的回复: 字节=32 时间=213ms TTL=49
来自 185.199.108.133 的回复: 字节=32 时间=197ms TTL=49
这样的话就可以成功初始化项目
npx nuxi init first-nuxt-app
√ Which package manager would you like to use?
pnpm
o Installing dependencies... 11:14:10
Packages: +683
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 751, reused 151, downloaded 532, added 683, done
node_modules/.pnpm/esbuild@0.20.1/node_modules/esbuild: Running postinstall script, done in 419ms