node.js - Hyperledger Composer 下的 MongoClient.connect 似乎在尝试实现 JWT 身份验证时抛出错误
问题描述
当我按照教程并尝试运行docker logs rest
它时会引发以下错误:我似乎不明白为什么
[2018-12-06 17:17:59] PM2 log: Launching in no daemon mode
[2018-12-06 17:17:59] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0
[2018-12-06 17:17:59] PM2 log: App name:composer-rest-server id:0 online
WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
Discovering types from business network definition ...
(node:19) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
预期输出:
docker logs rest
[2018-05-22 22:24:44] PM2 log: Launching in no daemon mode
[2018-05-22 22:24:44] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0
[2018-05-22 22:24:44] PM2 log: App name:composer-rest-server id:0 online
WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
Discovering types from business network definition ...
Discovered types from business network definition
Generating schemas for all types in business network definition ...
Generated schemas for all types in business network definition
Adding schemas for all types to Loopback ...
Added schemas for all types to Loopback
Web server listening at: http://localhost:3000
Browse your REST API at http://localhost:3000/explorer
[更新]:
[2018-12-08 04:01:58] PM2 log: Launching in no daemon mode
[2018-12-08 04:01:58] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0
[2018-12-08 04:01:58] PM2 log: App name:composer-rest-server id:0 online
WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
Discovering types from business network definition ...
解决方案
要摆脱警告消息,您需要将警告中指定的选项添加到 COMPOSER_DATASOURCES 环境变量中,例如
COMPOSER_DATASOURCES='{
"db": {
"name": "db",
"connector": "mongodb",
"host": "mongo",
"useNewUrlParser": "true"
}
}'
推荐阅读
- php - Laravel 访问 HasMany 关系的 BelongsTo 模型
- git - 每次我提交时都会删除 Composer 包
- chatbot - 如何在 Dialogflow 的 webhook 中执行插槽验证?
- javascript - 自动化 Priority-Web-SDK 文件上传
- django - Django-rest-auth 和 AWS - 错误 401
- fortran - Fortran 子例程参数在调用时被更改
- apache-spark - 从 PySpark 运行大量 Hive 查询
- arrays - 查找二维数组中有多少个圆的算法
- ios - 拆分视图控制器中的大标题奇怪行为
- javascript - 循环遍历vuejs中api响应的多维数组