zoukankan      html  css  js  c++  java
  • 记一次vuepress报错:UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function

    在使用vuepress时,按照官网的操作:

    在执行完vuepress之后,控制台出现:

    VuePress dev server listening at http://localhost:8080/

    当将  http://localhost:8080/   放入浏览器并确定时,会出现以下报错:

    (node:8960) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function
        at processRequest (D:刘威AmyProject0326vuepress-homepage
    ode_moduleswebpack-dev-middlewarelibmiddleware.js:82:18)
        at ready (D:刘威AmyProject0326vuepress-homepage
    ode_moduleswebpack-dev-middlewarelibutil.js:51:12)
        at handleRequest (D:刘威AmyProject0326vuepress-homepage
    ode_moduleswebpack-dev-middlewarelibutil.js:167:5)
        at Promise (D:刘威AmyProject0326vuepress-homepage
    ode_moduleswebpack-dev-middlewarelibmiddleware.js:44:7)
        at new Promise (<anonymous>)
        at middleware (D:刘威AmyProject0326vuepress-homepage
    ode_moduleswebpack-dev-middlewarelibmiddleware.js:43:12)
        at Promise.all.Promise (D:刘威AmyProject0326vuepress-homepage
    ode_moduleskoa-webpackindex.js:43:7)
        at new Promise (<anonymous>)
        at D:刘威AmyProject0326vuepress-homepage
    ode_moduleskoa-webpackindex.js:42:5
        at dispatch (D:刘威AmyProject0326vuepress-homepage
    ode_moduleskoa
    ode_moduleskoa-composeindex.js:42:32)
        at D:刘威AmyProject0326vuepress-homepage
    ode_modules@shellscapekoa-staticlegacyindex.js:58:19
        at Generator.throw (<anonymous>)
        at step (D:刘威AmyProject0326vuepress-homepage
    ode_modules@shellscapekoa-staticlegacyindex.js:6:221)
        at _throw (D:刘威AmyProject0326vuepress-homepage
    ode_modules@shellscapekoa-staticlegacyindex.js:6:455)
    (node:8960) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:8960) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,
    promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

    在这个问题中,通过查找vuepress的issuse我知道是: webpack-dev-middleware 这个中间件的原因。

    webpack-dev-middleware的作用就是:生成一个与webpack的compiler绑定的中间件,然后在express启动的服务app中调用这个中间件。

    个人推测(通过issuse里讨论):因为webpack-dev-middleware的版本过高,造成了不兼容,所以每次启动都会报这个错

    解决方法便是手动设置webpack-dev-middleware的版本:

    npm install webpack-dev-middleware@3.6.0

    设置成3.6.0版本,然后再一次加载全部依赖:

    npm install

    最后再次启动项目即可

  • 相关阅读:
    6-rocketmq-springboot整合
    5-rocketmq-事务消息
    3-rocketmq-支持的消息种类
    2-rocketmq-消息发送和接收
    1-rocketmq简介-部署
    详解unix5种IO模型
    大纲
    马哥博客作业第二十一周
    马哥博客作业第二十周
    马哥博客作业第十九周
  • 原文地址:https://www.cnblogs.com/liuwei54/p/10599592.html
Copyright © 2011-2022 走看看