VuePress報錯TypeError: res.getHeader is not a function

首先初始化一個項目

npm init -yvue

安裝vuepress

npm install -D vuepresswebpack

建立文件夾

mkdir docsgit

在docs下面建立README.md

echo '# Hello VuePress' > docs/README.mdgithub

添加package.json

{
  "scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  }
}
複製代碼

按照官方文檔的指示運行npm run docs:dev 進入本地環境時卻報了錯

Typ eError: res.getHeader is not a functionweb

最終在github中找到解決方法

運行npm install webpack-dev-middleware@3.6.0npm

或 修改成如下package.josn 重新安裝依賴

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

而後重新運行就能夠了

相關文章
相關標籤/搜索