Nuxt3项目初始化报错解决方案
问题:
官方初始化链接:https://nuxt.com/docs/getting-started/installation
执行下面初始化命令:
pnpm dlx nuxi init nuxt-app
执行后报错:
ERROR Error: Failed to download template from registry: request to https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json failed, reason: connect ETIMEDOUT 185.199.108.133:443 ERROR Command failed with exit code 1: nuxi init nuxt-app pnpm: Command failed with exit code 1: nuxi init nuxt-app at makeError (/usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:23113:17) at handlePromise (/usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:23684:33) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Object.handler [as dlx] (/usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:209846:7) at async /usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:217519:21 at async main (/usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:217488:34) at async runPnpm (/usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:217718:5) at async /usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:217710:7
解决方案:
在终端输入以下命令,测试是否连通
ping raw.githubusercontent.com
如果不联通,可以访问
https://ipaddress.com/website/raw.githubusercontent.com

然后再hosts中添加一行命令(我的是Mac环境,路径为:/etc/hosts)
185.199.108.133 raw.githubusercontent.com
以下是备用ip,如若上面ip不可行,可以尝试切换下面的ip
185.199.108.133 185.199.109.133 185.199.110.133 185.199.111.133 2606:50c0:8000::154 2606:50c0:8001::154 2606:50c0:8002::154 2606:50c0:8003::154
接下来执行如下命令
ping raw.githubusercontent.com
连同成功,继续执行Nuxt3初始化命令
pnpm dlx nuxi init nuxt-app
至此,初始化成功
✨ Nuxt project is created with v3 template. Next steps: 15:36:11 › cd nuxt-app 15:36:11 › Install dependencies with npm install or yarn install or pnpm install › Start development server with npm run dev or yarn dev or pnpm run dev
浙公网安备 33010602011771号