创建 nuxt3 项目时出错。无法从注册表下载模板
P粉469090753
P粉469090753 2023-11-01 23:50:03
0
2
748

当我使用此命令创建新的 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)

我的环境:

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

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

P粉469090753
P粉469090753

全部回复(2)
P粉287345251

我也遇到了同样的错误(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

这应该可以解决问题。

P粉633075725

我在此处找到了原因。

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

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!