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 進入本地環境時卻報了錯

Typ
eError: res.getHeader is not a function

最終在github中找到解決方法

運行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"
  }
}

而後重新運行就能夠了

相關文章
相關標籤/搜索