简体   繁体   English

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

[英]Error while creating nuxt3 project. Failed to download template from registry

When I use this command to create a new Nuxt 3 project:当我使用这个命令创建一个新的 Nuxt 3 项目时:

npx nuxi init nuxt-app

It outputs this error:它输出此错误:

 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)

My environments:我的环境:

  • Operating System: Windows 11操作系统:Windows 11
  • node version: 18.12.0节点版本:18.12.0
  • npm version: 8.12.1 npm 版本:8.12.1

At first I suspected that this was due to my.network.起初我怀疑这是由于 my.network。 But I didn't get an error when I tried to install other npm packages.但是当我尝试安装其他 npm 包时并没有报错。

I got the same issue while working at a client (bank), this is mainly a.network restriction indeed.我在客户(银行)工作时遇到了同样的问题,这确实主要是网络限制。 They are limiting the access to only a few NPM packages and this one is not whitelisted (mainly the template).他们只限制对少数 NPM 包的访问,而这个包没有列入白名单(主要是模板)。

Not sure how to properly bypass it other than manually getting the code with an SSH/HTTP clone or maybe asking them to allow that specific endpoint.除了使用 SSH/HTTP 克隆手动获取代码或者可能要求他们允许该特定端点之外,不确定如何正确绕过它。

I found the reason in here .我在这里找到了原因。

It's indeed a.network issue.这确实是一个网络问题。 It couldn't access raw.githubusercontent.com from the command line because it couldn't find the corresponding IP address.无法通过命令行访问raw.githubusercontent.com ,因为找不到对应的IP地址。

After adding the correct ip address of raw.githubusercontent.com to the Windows hosts file, the issue was fixed将raw.githubusercontent.com的正确ip地址添加到raw.githubusercontent.com hosts文件后,问题修复

You can also resolve it by switch your.network, like if you on using a wi-fi, please change it with another.你也可以通过切换你的.network来解决它,比如如果你正在使用wi-fi,请换成另一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM