创建 nuxt3 项目时出错。无法从注册表下载模板

Sta*_*ugz 8 javascript frontend vue.js nuxt.js nuxtjs3

当我使用此命令创建新的 Nuxt 3 项目时:

npx nuxi init nuxt-app
Run Code Online (Sandbox Code Playgroud)

它输出这个错误:

 ERROR  (node:1752) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time                         09:53:25
(Use `node --trace-warnings ...` to show where the warning was created)


 ERROR  Failed to download template from registry: fetch failed                                                                                  09:53:25

  at /C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13269:11
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async downloadTemplate (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13268:20)
  at async Object.invoke (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13336:15)
  at async _main (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/cli.mjs:50:20)
Run Code Online (Sandbox Code Playgroud)

我的环境:

  • 操作系统:Windows 11
  • 节点版本:18.12.0
  • npm 版本:8.12.1

起初我怀疑这是由于我的网络造成的。但是当我尝试安装其他 npm 包时没有收到错误。

Sta*_*ugz 2

我在这里找到了原因。

确实是网络问题。无法raw.githubusercontent.com从命令行访问,因为找不到对应的IP地址。

将正确的IP地址添加raw.githubusercontent.com到Windows主机文件后,问题得到解决