首页  >  问答  >  正文

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

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

npx nuxi init nuxt-app

它输出此错误:

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)

我的环境:

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

P粉469090753P粉469090753322 天前751

全部回复(2)我来回复

  • P粉287345251

    P粉2873452512023-11-02 10:12:05

    我也遇到了同样的错误(Windows 10)。我的很简单。

    ERROR  Error: Failed to download template from registry: fetch failed

    是的,这与网络或IP被阻止有关。不过我还是设法解决了。这就是我所做的。

    首先进入C:\Windows\System32\drivers\etc

    在此文件夹中查找“hosts”文件。用记事本以管理员身份打开。现在在文件末尾(以及其他 IP 地址)添加此行。

    // Some other ip address
    185.199.108.133 raw.githubusercontent.com

    这应该可以解决问题。

    回复
    0
  • P粉633075725

    P粉6330757252023-11-02 09:23:29

    我在此处找到了原因。

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

    raw.githubusercontent.com 的正确 IP 地址添加到 Windows 主机文件后,问题已修复

    回复
    0
  • 取消回复