2

首先初始化一个项目

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

然后从新运行就可以了


cchao
5 声望0 粉丝