参考 https://www.jianshu.com/p/5bda5556c149

安装 Mongo并启动

安装yapi-cli

npm install -g yapi-cli

启动

yapi server

浏览器打开

http://0.0.0.0:9090/

  • 问题1:初始化数据库报错
    Error: (node:90198) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

Yapi本地搭建及错误解决_IT

解决方法
cd ~/my-yapi/vendors
vim exts/server/utils.js 22行 添加 useUnifiedTopology: true

 let options = {useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true};

参考官网的命令行部署方式 https://hellosean1025.github.io/yapi/devops/index.html

npm run install-server
  • 问题2:初始化管理员账号失败

Yapi本地搭建及错误解决_IT_02

解决方法:删除mongodb数据库中已创建的管理员数据,重新运行

Mac OS可以使用 NoSQL Booster客户端连接Mongodb,如下图:

Yapi本地搭建及错误解决_IT_03

Yapi本地搭建及错误解决_Yapi_04

初始化管理员账号成功,账号名:"superhin@126.com",密码:"ymfe.org"

启动服务

cd  ~/my-yapi
node vendors/server/app.js

访问网站

http://127.0.0.1:3000/ 使用账号 密码登录即可
Yapi本地搭建及错误解决_IT_05

官方使用教程:https://hellosean1025.github.io/yapi/

接口请求插件安装

Yapi本地搭建及错误解决_Yapi_06

  • 点击[点击下载]连接,解压下载的crossRequest.zip得到cross-request.crx
  • 修改cross-request.crx后缀名为.rar,解压后得到cross-request目录
  • 浏览器打开chrome://extensions/,打开开发者模式,点击 加载已解压的扩展程序,选择cross-request目录即可

Yapi本地搭建及错误解决_IT_07