Error: Cannot find module 'json-schema-faker' YAPI部署

大家好,我是烤鸭:

       采坑实录。

       安装 YAPI 接口项目时出现的这个问题,如果你不是这个情况出现的这个报错,就不用继续看了。

       YAPI的 github 地址:

       https://github.com/YMFE/yapi

 

1.场景

     安装 YAPI 接口项目。当时日志没找,从github的看到有人提的issue,跟我的一样,如下。

 

2.报错信息

当前安装版本: 1.5.7
连接数据库成功!
开始下载平台文件压缩包...
http://registry.npm.taobao.org/yapi-vendor/download/yapi-vendor-1.5.7.tgz
部署文件完成,正在安装依赖库...
npm
WARN
deprecated
nomnom@1.5.2: Package no longer supported. Contact support@npmjs.com for more info.

jsonpath@1.0.0 postinstall /data/my-yapi/vendors/node_modules/jsonpath > node lib/aesprim.js > generated/aesprim-browser.js
sh: generated/aesprim-browser.js: Permission denied
npm
WARN
eslint-config-modular@4.2.2 requires a peer of eslint@>=3.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
mongoose-auto-increment@5.0.1 requires a peer of mongoose@^4.1.12 but none is installed. You must install peer dependencies yourself.
npm
WARN
yapi-vendor@1.4.4 license should be a valid SPDX license expression
npm
WARN
The package moment is included as both a dev and production dependency.
npm
ERR!
code
ELIFECYCLE
npm
ERR!
errno
1
npm
ERR!
jsonpath@1.0.0 postinstall: node lib/aesprim.js > generated/aesprim-browser.js
npm
ERR!
Exit status 1
npm
ERR!
npm
ERR!
Failed at the jsonpath@1.0.0 postinstall script.
npm
ERR!
This is probably not a problem with npm. There is likely additional logging output above.
npm
ERR!
A complete log of this run can be found in:
npm
ERR!
/root/.npm/_logs/2019-02-11T09_05_54_645Z-debug.log
依赖库安装完成,正在初始化数据库mongodb...
yapi-vendor@1.4.4 install-server /data/my-yapi/vendors > node server/install.js
Error: module.js:540 throw err; ^ Error: Cannot find module 'json-schema-faker' at Function.Module._resolveFilename (module.js:538:15) at Function.Module._load (module.js:468:25) at Module.require (module.js:587:17) at require (internal/module.js:11:18) at Object. (/data/my-yapi/vendors/server/utils/commons.js:19:13) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Module.require (module.js:587:17) at require (internal/module.js:11:18) at Object. (/data/my-yapi/vendors/server/install.js:3:17) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32)

3.原因及解决方案

      这个错误的原因在于 nodejs 的 运行权限和运行 yapi -server 的权限不一致。

      解决:

chown -R root:root /nodejs安装目录(环境变量配置的目录)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

烤鸭的世界我们不懂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值