zoukankan      html  css  js  c++  java
  • docusaurus 启动出错 Error: getaddrinfo ENOTFOUND localhost

    解决方法

    检查hosts文件, 应该是localhost没了
    添加

    127.0.0.1 localhost
    

    起因

    想要翻译文档, 打算使用 docusaurus

    根据文档执行

    npx create-docusaurus@latest my-website classic
    

    后创建项目成功, 安装依赖一切正常

    当我执行 start 时遇到错误

    yarn run v1.22.17
    $ docusaurus start
    [INFO] Starting the development server...
    [SUCCESS] Docusaurus website is running at http://localhost:3000/.
    
    ● Client █████████████████████████ setup (3%)  
     watch run
    
    (node:40311) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
    (Use `node --trace-deprecation ...` to show where the warning was created)
    /Users/sftc/Desktop/my-website/node_modules/webpack-dev-server/lib/Server.js:2440
            throw error;
            ^
    
    Error: getaddrinfo ENOTFOUND localhost
        at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
      errno: -3008,
      code: 'ENOTFOUND',
      syscall: 'getaddrinfo',
      hostname: 'localhost'
    }
    error Command failed with exit code 1.
    

    我们应该会下意识看到第一句Warning把它当成报错, 实际上这个不会影响运行

    饶了好大一圈, 看到了这个回答 Cant load a react app after starting server

    It's just a deprecation warning from one of the libraries you used within the app, have you tried to open http://localhost:3000 on your local? it is supposed to be running fine

    我当然是看项目没跑起来才搜索报错原因的啊

    我开始怀疑node版本问题, 怀疑人生

    这就是拿着半截就跑...

    终于仔细检查发现

    Error: getaddrinfo ENOTFOUND localhost
    

    这才是罪魁祸首, 原来是公司的VPN修改了hosts文件, 把localhost干掉了

    无个性不签名
  • 相关阅读:
    1206 冲刺三
    1130持续更新
    1128项目跟进
    冲刺一1123(总结)
    冲刺一
    1117 新冲刺
    0621 第三次冲刺及课程设计
    0621回顾和总结
    实验四主存空间的分配和回收
    学习进度条
  • 原文地址:https://www.cnblogs.com/qinweijie/p/15729742.html
Copyright © 2011-2022 走看看