VuePress报错TypeError: res.getHeader is not a function

首先初始化一个项目

npm init -y

安装vuepress

npm install -D vuepress

创建文件夹

mkdir docs

在docs下面创建README.md

echo ‘# Hello VuePress’ > docs/README.md

添加package.json

{
  "scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  }
}

按照官方文档的指示运行npm run docs:dev 进入本地环境时却报了错

《VuePress报错TypeError: res.getHeader is not a function》

Typ

eError: res.getHeader is not a function

最终在github中找到解决方法

《VuePress报错TypeError: res.getHeader is not a function》

运行npm install webpack-dev-middleware@3.6.0

或 修改为以下package.josn 从新安装依赖

{
  "scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  },
  "devDependencies": {
    "vuepress": "^0.14.10",
    "webpack-dev-middleware": "3.6.0"
  }
}

然后从新运行就可以了

    原文作者:cchao
    原文地址: https://segmentfault.com/a/1190000018511676
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞