Got error when check update: Connect timeout for 5000ms, GET https://registry.npmjs.org/egg-init/lat

在egg的时候,根据文档的方式创建项目,但是一直失败:

suchcl@DESKTOP-EH6OH7F:/mnt/d/WebStudy/EggApp$ npm init egg --type=simple
npx: installed 396 in 20.017s
[egg-init] use registry: https://registry.npmjs.org
Got error when check update: Connect timeout for 5000ms, GET https://registry.npmjs.org/egg-init/latest -2 (connected: false, keepalive socket: false, socketHandledRequests: 1, socketHandledResponses: 0)
headers: {}
[egg-init] target dir is /mnt/d/WebStudy/EggApp
[egg-init] fetching npm info of egg-init-config
[egg-init] use fallback from egg-init-config
[egg-init] use boilerplate: simple(egg-boilerplate-simple)
[egg-init] fetching npm info of egg-boilerplate-simple
ResponseTimeoutError: Response timeout for 5000ms, GET https://registry.npmjs.org/egg-boilerplate-simple/latest 200 (connected: true, keepalive socket: false, socketHandledRequests: 1, socketHandledResponses: 1)
headers: {"date":"Tue, 10 Nov 2020 06:05:57 GMT","content-type":"application/json","transfer-encoding":"chunked","connection":"keep-alive","set-cookie":["__cfduid=dd4e69410af7f56375659ca707afa43481604988357; expires=Thu, 10-Dec-20 06:05:57 GMT; path=/; domain=.npmjs.org; HttpOnly; SameSite=Lax"],"cf-ray":"5efd95b058280280-SJC","vary":"Accept-Encoding","cf-cache-status":"DYNAMIC","cf-request-id":"06525be23900000280f70ea000000001","expect-ct":"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"","server":"cloudflare"}
    at Timeout._onTimeout (/home/suchcl/.npm/_npx/3154/lib/node_modules/create-egg/node_modules/urllib/lib/urllib.js:960:15)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

根源是不能正常使用https://registry.npmjs.org这个源,那我们就通过设置指定源的方式创建项目就可以了:

npm init egg -r=https://registry.npm.taobao.org 指定taobao源

suchcl@DESKTOP-EH6OH7F:/mnt/d/WebStudy/EggApp/egg2$ npm init egg -r=https://registry.npm.taobao.org --type=simple
[##................] \ loadDep:socks-proxy-agent: sill resolveWithNewModule yallist@3.1.1 checking installable status
npx: installed 396 in 160.073s
[egg-init] use registry: https://registry.npm.taobao.org
[egg-init] target dir is /mnt/d/WebStudy/EggApp/egg2
[egg-init] fetching npm info of egg-init-config
[egg-init] use boilerplate: simple(egg-boilerplate-simple)
[egg-init] fetching npm info of egg-boilerplate-simple
[egg-init] downloading https://registry.npm.taobao.org/egg-boilerplate-simple/download/egg-boilerplate-simple-3.3.1.tgz
[egg-init] extract to /tmp/egg-init-boilerplate
[egg-init] collecting boilerplate config...
? project name egg2
? project description egg2
? project author yanshijing
? cookie security keys 1604992596502_3035
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/.autod.conf.js
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/.eslintignore
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/.eslintrc
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/README.md
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/.gitignore
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/package.json
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/app/router.js
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/config/config.default.js
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/config/plugin.js
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/app/controller/home.js
[egg-init] write to /mnt/d/WebStudy/EggApp/egg2/test/app/controller/home.test.js
[egg-init] usage:
      - cd /mnt/d/WebStudy/EggApp/egg2
      - npm install
      - npm start / npm run dev / npm test

创建成功,问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值