You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React项目安装gh-pages遇ENOTFOUND错误求助

解决gh-pages安装报错ENOTFOUND的方法

问题核心

错误日志显示请求地址http://toju-toby22.githuub.io/my-app存在拼写错误——github被误写为githuub,导致DNS解析失败,这是安装失败的关键原因。

具体解决步骤

  • 打开项目根目录下的package.json文件,检查homepage字段,将地址中的githuub修正为github,正确格式示例:
    "homepage": "https://toju-toby22.github.io/my-app"
    
  • 清除npm缓存,执行命令:
    npm cache clean --force
    
  • 重新安装gh-pages:
    npm install gh-pages --save-dev
    
  • 若问题仍存在,检查并重置npm网络配置:
    • 查看当前代理设置:
      npm config get proxy
      npm config get https-proxy
      
    • 若存在错误代理,清空设置:
      npm config delete proxy
      npm config delete https-proxy
      
  • 国内用户可切换至国内npm镜像源后重试:
    npm config set registry https://registry.npmmirror.com/
    npm install gh-pages --save-dev
    

原始错误信息

$ npm install gh-pages --save-dev
npm ERR! code ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! errno ENOTFOUND
npm ERR! network request to http://toju-toby22.githuub.io/my-app failed, reason: getaddrinfo ENOTFOUND toju-toby22.githuub.io
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\u\AppData\Local\npm-cache_logs\2022-11-20T22_50_58_984Z-debug-0.log

内容的提问来源于stack exchange,提问作者Tobi Otoju

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 05:01:11