Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YApi 安装出现问题请看这里 #16

Open
hellosean1025 opened this issue Nov 2, 2017 · 123 comments
Open

YApi 安装出现问题请看这里 #16

hellosean1025 opened this issue Nov 2, 2017 · 123 comments
Labels

Comments

@hellosean1025
Copy link
Member

hellosean1025 commented Nov 2, 2017

  1. 确保 node 版本=> 7.6,请运行 node -v 查看版本号
  2. 确保 mongodb 版本 => 2.6,请运行 mongo --version 查看版本号
  3. 确保安装了 npm, 运行 npm -v 查看版本号
  4. 确保安装了 git,运行 git --version 查看版本号
  5. 确保安装了 node-gyp 环境,配置方法

确认版本号没问题,请删除原有的安装文件和数据库,重新安装。

如果安装了 yapi-cli 工具,执行 yapi server 找不到命令,可尝试执行 yapi-cli server

如果是使用了yapi server 可视化部署出的问题,可查看下文档-> 内网部署方式,熟悉 docker 童鞋可以使用 docker 部署,docker 部署的教程可以在 https://github.com/YMFE/yapi 这里找到。

如果还是无法安装,请不要选择最新的版本,可选择上一个版本或上上一个版本等,最新版本出问题的概率会比较大。

有问题请在下面留言,感谢大家的反馈。

@hellosean1025 hellosean1025 changed the title YApi 安装出现问题请看这里 YApi 安装出现问题请看这里 #安装 Nov 2, 2017
@hellosean1025 hellosean1025 changed the title YApi 安装出现问题请看这里 #安装 YApi 安装出现问题请看这里 Nov 2, 2017
@darkless456
Copy link

darkless456 commented Nov 28, 2017

请问如果nginx反代到yapi的3000端口,怎么办,内网访问yapi无问题

我是这么设置的

	location ^~ /api/ {
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_pass      http://127.0.0.1:3000;
	}

但是不行

@hellosean1025
Copy link
Member Author

@darkless456 我这边是这样配置的

 location / {
            proxy_http_version 1.1;
	    proxy_set_header Upgrade $http_upgrade;
	    proxy_set_header Connection "upgrade";
            proxy_pass   http://127.0.0.1:3011;
    }

@juntingl
Copy link

juntingl commented Feb 23, 2018

博主, 我使用的是内网部署方式2,部署到自己服务器上,在进行npm run install-server时,会报

error: MongoError: auth failed, mongodb Authentication failed
error: MongoError: auth failedmongodb connect error

根据官网 centos 环境搭建的基础环境,连接mongo 还会报错这是什么原因?

@juntingl
Copy link

@darkless456 你好,想问你下,你内网部署成功了嘛?

@hellosean1025
Copy link
Member Author

Authentication failed 一般是因为数据库权限问题,建议第一次安装 mongodb 不要开启权限认证,config 配置文件也不需要填写数据库用户名和密码,等熟悉了再考虑设置 mongodb 权限。
@Twitchboy @dzjwan521

@joriewong
Copy link

@Twitchboy @dzjwan521

# mongo
> db.createUser({user:'test1',pwd:'test1',roles:[{role:'root',db:'admin'}]})
> db.auth('test1','test1')

# service mongod stop
# service mongod start

@ChaNHHHHH
Copy link

部署问题
Error: WARNING: The useMongoClient option is no longer necessary in mongoose 5.x, please remove it.

@stringstru
Copy link

[root@struggle ~]# yapi server
在浏览器打开 http://0.0.0.0:9090 访问。非本地服务器,请将 0.0.0.0 替换成指定的域名或ip
/bin/sh: xdg-open: command not found

@wei772
Copy link

wei772 commented Apr 10, 2018

你们不支持nginx代理吧
image

@flynntsc
Copy link

@stringstru 先安装/重装下xdg-utils

sudo apt-get install --reinstall xdg-utils

@undeadwing
Copy link

请问部署的时候一直报权限问题怎么解决啊

node lib/aesprim.js > generated/aesprim-browser.js
sh: generated/aesprim-browser.js: Permission denied

最后会导致
Error: Cannot find module 'json-schema-faker'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/bigdata/yapi/vendors/server/utils/commons.js:23:13)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/bigdata/yapi/vendors/server/install.js:3:17)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)

@lushenchen
Copy link

您好,请问使用文档内网内否使用?

@hellosean1025
Copy link
Member Author

@undeadwing 删除 node_modules 重新 npm install --production 试试

@hellosean1025
Copy link
Member Author

@ChaNHHHHH 警告错误,不用管

@yrzty21
Copy link

yrzty21 commented May 7, 2018

@suxiaoxin 请帮忙看下安装依赖时出现的问题

问题提示如下:
[localhost:vendors yrzty$ npm install --production --registry https://resgistry.npm.taobao.org
npm WARN [email protected] license should be a valid SPDX license expression

npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://resgistry.npm.taobao.org/btoa failed, reason: getaddrinfo ENOTFOUND resgistry.npm.taobao.org resgistry.npm.taobao.org:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/yrzty/.npm/_logs/2018-05-07T04_05_58_093Z-debug.log
[localhost:vendors yrzty$
环境是macos 10.11.6 node版本:10.0.0 npm版本:5.6.0 mongodb安装的是[email protected]
2018-05-07T04_05_58_093Z-debug.log

补充:没有设定proxy,安装其他软件也OK啊,网络可以正常访问。

@kwen8
Copy link

kwen8 commented May 9, 2018

>  node server/install.js

 log: mongodb load success...

Error:  (node:3365) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: 初始化管理员账号 "[email protected]" 失败, E11000 duplicate key error collection: yapi.user index: email_1 dup key: { : "[email protected]" }

初始化管理员账号[email protected]失败是什么原因呢?是不能用这个邮箱吗?

@zheyvsu
Copy link

zheyvsu commented May 13, 2018

update 失败, 现象如下。

环境是在华为云Centos7.4上会出这个问题。 在本机linux不这样。

fatal: unable to access 'https://github.com/nhnent/raphael.git/': Peer reports incompatible or unsupported protocol version.

@zheyvsu
Copy link

zheyvsu commented May 13, 2018

解决了。
执行下面这个命令。

yum update -y nss curl libcurl

如果还不行,再更新一下git版本。升级到2.x

@SHERlocked93
Copy link

感谢yapi群里的 @小容 的解答,我用她提供的方法成功跑起来了:

一、配置MongoDB
第一步:创建数据库
use yapi
第二步:创建用户并配置权限
db.createUser({user:"username",pwd:"123456",roles:[{"role":"readWrite","db":"yapi"}]})

二、配置YApi(config.json)

"db": {
   "servername": "127.0.0.1",
   "DATABASE": "yapi",
   "port": 27017,
   "user": "username",
   "pass": "123456",
   "authSource": ""
 }

@stoneFive
Copy link

stoneFive commented May 17, 2018 via email

@magicds
Copy link

magicds commented May 24, 2018

运行 yapi server 浏览器中点击开始部署过程中出现以下错误:

部署文件完成,正在安装依赖库...

> [email protected] install D:\xampp\htdocs\api\my-yapi\vendors\node_modules\dtrace-provider
> node-gyp rebuild || node suppress-error.js


D:\npm\npm_global\node_modules\yapi-cli\node_modules\ws\lib\WebSocket.js:358
      else throw new Error('not opened');
           ^

Error: not opened
    at WebSocket.send (D:\npm\npm_global\node_modules\yapi-cli\node_modules\ws\lib\WebSocket.js:358:18)
    at Socket.<anonymous> (D:\npm\npm_global\node_modules\yapi-cli\src\commands\server.js:66:16)
    at emitOne (events.js:121:20)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:246:13)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:597:20)

OS: windows 10,
node version: 10.1.0 9.2.0 8.11.2
mongo version: v3.2.7
yapi version: v1.3.15 v1.3.16

@hellosean1025
Copy link
Member Author

@cdswyda 确保安装了 node-gyp 环境,配置方法

@magicds
Copy link

magicds commented May 24, 2018

@hellosean1025 thank you. node-gyp 的环境应该是没有问题的, 最后以本地部署的命令行方式顺利完成了。

@MRwangyd
Copy link

您好,我使用命令行部署后,启动正常,但是没有yapi命令,
image

@Shen120
Copy link

Shen120 commented Aug 1, 2021

实测有效安装方法 2020年12月20日

主要修改了以下内容:

  1. node14 版本必须 < 15

  2. 通过官方文档的手动安装并修改部分内容

    1. 修改 config.json
    2. 删除 package-lock.json

本地主机:MacOS 10.16.7

环境:

  • HomeBrew
  • mongodb 4.4.1(通过 HomeBrew 安装)
  • node 14(通过 HomeBrew 安装)⚠️ 特别注意:一定要 < 15(亲测15版本Node会报依赖错误)
  • YApi(依赖Node & mongodb)
  • pm2(依赖Node 来保护YApi进程)

安装过程:

HomeBrew 略

mongodb 略

node@14 略

pm2 略

YApi手动部署:

安装-手动

mkdir yapi 
cd yapi 
git clone https://github.com/YMFE/yapi.git vendors 
cp vendors/config_example.json ./config.json // ⚠️  复制完成后把内容修改为 config.json
cd vendors 
rm package-lock.json // ⚠️ 一定要删除 package-lock.json 
npm install --production --registry https://registry.npm.taobao.org 
npm run install-server 
node server/app.js 

config.json 参考

{
  "port": "3000",
  "adminAccount": "[email protected]",
  "timeout":120000,
  "db": {
    "servername": "127.0.0.1",
    "DATABASE": "yapi",
    "port": 27017
  },
  "mail": {
    "enable": false,
    "host": "smtp.163.com",
    "port": 465,
    "from": "***@163.com",
    "auth": {
      "user": "***@163.com",
      "pass": "*****"
    }
  }
}

必须顶你,我用yapi server出错无数次,你的方法一次成功
环境:

node: v14.17.2
MongoDB: v4.4.6

@ghost
Copy link

ghost commented Aug 12, 2021

当启动时候,访问地址时候就显示空白,然后就允运行出错

当前node:v8.12.0
npm:6.4.1
mongoDB:mongo:4.4

~~~
log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
log: 服务已启动,请打开下面链接访问:
http://127.0.0.1:3000/
log: mongodb load success...

Error: write EPIPE
at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)

Error: write ECONNRESET
at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)
~~~

当启动时候,访问地址时候就显示空白,然后就允运行出错

当前node:v8.12.0
npm:6.4.1
mongoDB:mongo:4.4

~~~
log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
log: 服务已启动,请打开下面链接访问:
http://127.0.0.1:3000/
log: mongodb load success...

Error: write EPIPE
at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)

Error: write ECONNRESET
at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)
~~~

找到问题根源所在,解决问题方式
chmod -R 777 /var/lib/nginx/proxy
image

@master-start
Copy link

npm fund 执行显示 [email protected],yapi执行显示1.10.1,登录后台后显示请升级,后台功能都不正常了
。。。。。。。。已经升级到最新,还要提示我升级。。。。。。。
微信图片_20210903171112

@pikadun
Copy link

pikadun commented Sep 23, 2021

为什么会出现你们的内网域名啊 https://repo.corp.qunar.com

@q1979635364
Copy link

Accessing non-existent property 'count' of module exports inside circular dependency

我把nodejs换成低版本(v10.19.0)的就可以了

@usernameisnull
Copy link

[root@dev-infra ~]# yapi server
在浏览器打开 http://0.0.0.0:9090 访问。非本地服务器,请将 0.0.0.0 替换成指定的域名或ip
(node:19879) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
(node:19879) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:19879) Warning: Accessing non-existent property 'which' of module exports inside circular dependency

你们做的东西是认真的么?血压都上来了,一运行就报一堆这个,点击页面部署一直转圈,然后啥也没有?
能严肃点么。。。错误日志呢?

[root@dev-infra ~]# node -v
v14.18.1

[root@dev-infra ~]# mongo version
MongoDB shell version v5.0.3
connecting to: mongodb://127.0.0.1:27017/version?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("45f7c1ef-a1c7-4014-8640-b69e31460d1d") }
MongoDB server version: 5.0.3

[root@dev-infra ~]# git version
git version 1.8.3.1

[root@dev-infra ~]# node-gyp -v
v8.4.0

@usernameisnull
Copy link

image

@tmlx1990
Copy link

yapi版本:1.10.2
node.js: v16.13.0
npm: 8.1.0
使用npm install --production --registry https://registry.npm.taobao.org 安装时报如下错误
npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/dify/download/dify-1.0.5.tgz failed, reason: connect ETIMEDOUT 10.66.160.10:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'

@TaixiangLu
Copy link

yapi版本:1.10.2
npm install 报错
http://npmrepo.corp.qunar.com/tslib/-/tslib-1.8.0.tgz 这个地址访问不了

npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://npmrepo.corp.qunar.com/tslib/-/tslib-1.8.0.tgz failed, reason: connect ETIMEDOUT 10.66.160.10:80
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'

@tmlx1990
Copy link

yapi版本:1.10.2 npm install 报错 http://npmrepo.corp.qunar.com/tslib/-/tslib-1.8.0.tgz 这个地址访问不了

npm ERR! code ETIMEDOUT npm ERR! syscall connect npm ERR! errno ETIMEDOUT npm ERR! network request to http://npmrepo.corp.qunar.com/tslib/-/tslib-1.8.0.tgz failed, reason: connect ETIMEDOUT 10.66.160.10:80 npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config'

尝试换到taobao的试试

@JavonLuo
Copy link

JavonLuo commented Dec 1, 2021

Authentication failed 一般是因为数据库权限问题,建议第一次安装 mongodb 不要开启权限认证,config 配置文件也不需要填写数据库用户名和密码,等熟悉了再考虑设置 mongodb 权限。 @Twitchboy @dzjwan521

把config.js中的用户名和密码 改成空字符串 就可以了

@ihupoo
Copy link

ihupoo commented Dec 3, 2021

安装 npm依赖问题 太大了,完全装不上。。。

@meiruihao
Copy link

mongodb Authentication failed问题,发现这个方法是可以的。
转载自:https://blog.csdn.net/qq_20794095/article/details/102971774

@WangJincheng4869
Copy link

[root@dev-infra ~]# yapi server 在浏览器打开 http://0.0.0.0:9090 访问。非本地服务器,请将 0.0.0.0 替换成指定的域名或ip (node:19879) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency (Use node --trace-warnings ... to show where the warning was created) (node:19879) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'find' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'head' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'set' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'test' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'to' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency (node:19879) Warning: Accessing non-existent property 'which' of module exports inside circular dependency

你们做的东西是认真的么?血压都上来了,一运行就报一堆这个,点击页面部署一直转圈,然后啥也没有? 能严肃点么。。。错误日志呢?

[root@dev-infra ~]# node -v v14.18.1

[root@dev-infra ~]# mongo version MongoDB shell version v5.0.3 connecting to: mongodb://127.0.0.1:27017/version?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("45f7c1ef-a1c7-4014-8640-b69e31460d1d") } MongoDB server version: 5.0.3

[root@dev-infra ~]# git version git version 1.8.3.1

[root@dev-infra ~]# node-gyp -v v8.4.0
还是手动部署吧,那个自动部署我也是没成功,但是手动部署一次成功!

@shibin-cli
Copy link

可以yapi脚手架上加个命令指定端口号吗?这样使用更加方便

yapi server -p 9001

@13116176539
Copy link

image
使用官网提供的命令行部署.
npm install --production --registry https://registry.npm.taobao.org
然后就报错了.这个怎么解决?

@13116176539
Copy link

我解决了这个问题.是node版本太高了.降低版本就ok,我是降到了12.20.0

@liubaohong1
Copy link

Error: getaddrinfo ENOTFOUND yapi.demo.qunar.com

@liubaohong1
Copy link

请问这个是什么原因呢

@tmlx1990
Copy link

Error: getaddrinfo ENOTFOUND yapi.demo.qunar.com

你把package-lock.json删了试试

@mingregister
Copy link

请问怎么指定监听的ip呢? 只能监听127.0.0.1么?

@hippora
Copy link

hippora commented Jun 15, 2022

有谁把依赖问题解决一下吗?nodejs LTS都v16了啊。

@solxnp
Copy link

solxnp commented Jun 28, 2022

这都什么乱七八糟的依赖关系 里面一堆repo.corp.qunar.com的包,都访问不了!删了lock.json,又报各种包版本冲突

@hooklab
Copy link

hooklab commented Aug 15, 2022

经过测试,部署都这么困难就不用了 npm 有关的就是麻烦

@Dosia96
Copy link

Dosia96 commented Oct 20, 2022

部署成功,捣鼓了一下午,把我遇到的问题整理一下:
使用yapi-cli部署失败,最终采取的是https://github.com/YMFE/yapi/blob/master/docs/devops/index.md 内网部署方式2命令行部署,也比较符合平时使用node的习惯(git clone仓库,npm i安装依赖,node app.js启动服务)

问题1:循环依赖问题:
类似于Warning: Accessing non-existent property 'cat' of module exports inside circular dependency一大堆“circular dependency”问题,这个好像是因为高版本的node不支持循环依赖了,解决方法是,更换node版本,文章中说node版本高于7.6,但是实际上不能高太多,我用n工具替换了版本问题解决
linux终端输入:

  • sudo npm install -g n - 全局安装n
  • n v7.7.0 - 安装nodev7.7.0版本
  • 输入n,然后选择7.7.0版本切换使用
  • 然后再执行之前的步骤,解决

问题2:yapi.demo.qunar.com问题
这个看到有人遇到了类似的问题,需要找到自己系统全局npm包(node_modules)安装的位置
我是使用 npm config get prefix,找到/usr/local/bin下有npm的软链,然后命令行“ll”找到该软链的位置,
最后在 /usr/local/lib/node_modules/yapi-cli/src/commands找到了server.js,并注释了32-36行(if config.company部分)
不过这个好像是解决yapi-cli部署遇到的问题,最后我没有用这个方法。

问题3:mongodb问题
我首先使用mongoDB shell工具自行连接mongo确保数据库没问题:https://www.mongodb.com/try/download/community

如:wget https://fastdl.mongodb.org/linux/mongodb-shell-linux-x86_64-rhel70-5.0.6.tgz
解压,进入目录
./bin/mongo -u{用户名} -p{密码} {替换自己的IP}:27017/admin,大括号部分直接替换,不带大括号。
上述命令成功后会进入mongoDB的命令行界面,下文复制了前面一个大佬的回复:
第一步:创建数据库
use yapi
第二步:创建用户并配置权限
db.createUser({user:"username",pwd:"123456",roles:[{"role":"readWrite","db":"yapi"}]})

然后在自己的config.json修改用户名密码,(部署步骤中有cp配置文件的操作,可以找到该路径)

如果遇到认证失败的问题,试着将配置文件中authSource值设置为:"authSource": "admin"

问题4:npm install --production --registry https://registry.npm.taobao.org太慢问题
执行这个命令等了我好久,后来发现我带上taobao的执行太慢,直接删掉执行npm install很快就装完了。
如果还是慢可以再换几个镜像源,方法百度即可。

总的来说可部署的比较完善的web api平台YApi做的还是很完善和优秀的,就是部署的时候踩了一些坑XD

@Maplejay
Copy link

Maplejay commented Nov 12, 2022

执行 yapi update
(node:5842) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
(node:5842) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:5842) Warning: Accessing non-existent property 'which' of module exports inside circular dependency
更新版本为v1.4.1
开始下载平台文件压缩包...
http://yapi.demo.qunar.com/publicapi/archive/v1.4.1
Error: getaddrinfo ENOTFOUND yapi.demo.qunar.com


现在哪个版本最稳定的?
如何解决??
阿里云提示:Yapi api接口 MongoDB注入致远程命令执行漏洞,哪个版本修复这个问题

@libaocai90
Copy link

libaocai90 commented Nov 14, 2022

同样是报 Error: getaddrinfo ENOTFOUND yapi.demo.qunar.com
换过node版本,改过package-lock.json, 不好使。
于是采用了一个大道至简的办法, 关闭注册、关闭mock。

{
   "port": "3000",
   "closeRegister":true,
   "mock": false,
   "adminAccount": "[email protected]",
   "db": {
      "servername": "127.0.0.1",
      "DATABASE": "yapi",
      "port": "27017"
   },
   "mail": {
      "enable": false,
      "host": "smtp.163.com",
      "port": 465,
      "from": "***@163.com",
      "auth": {
         "user": "***@163.com",
         "pass": "*****"
      }
   }
}

@xwj-vic
Copy link

xwj-vic commented Jun 3, 2023

所有问题看这里就可以解决了,折腾了好久总结出来的:https://blog.opendeveloper.cn/yapi

@gozeon
Copy link

gozeon commented Apr 28, 2024

https://github.com/gozeon/yapii

@ailinuxok
Copy link

真tmd的浪费时间,一堆问题,我用Mongodb的管理员账号去连接,居然报没有权限,算了不用了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests