问题描述
我正在尝试连接到我在MLab托管的数据库.我正在使用StrongLoop API.我已将托管数据库的配置信息放入datasources.json和config.json文件中,但是每当使用npm start
运行目录时,都会在api \ node_modules \ mongodb \ lib \ url_parser.js中获取throw new Error ('double colon in host identifier';)
:45.
I am trying to connect to a database that I have hosted at MLab. I am using the StrongLoop API. I've placed the config information for my hosted databases into my datasources.json and config.json files, but whenever I run the directory with npm start
, I get throw new Error ('double colon in host identifier';)
at api\node_modules\mongodb\lib\url_parser.js:45.
我还确保安装了loopback-connecter-mongodb npm软件包.
I have also made sure to install the loopback-connecter-mongodb npm package.
以下是 datasources.json 的代码段(当然,没有实际的数据库详细信息):
Here is a snippet of datasources.json (without the actual database details, of course):
{
"db": {
"name": "db",
"connector": "mongodb",
"host": "ds047355.mlab.com",
"database": "dbtest",
"username": "user",
"password": "fakepassword",
"port": 47355
}
}
这是 config.json 文件:
{
"restApiRoot": "/api",
"host": "ds047355.mlab.com",
"port": 47355,
"remoting": {
"context": {
"enableHttpContext": false
},
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"errorHandler": {
"disableStackTrace": false
}
},
"legacyExplorer": false
}
有什么想法吗?
推荐答案
我终于解决了导致此错误的问题.它正在以 http://0.0.0.0/:8080 的形式读取我的服务器URL. ,但在我更改为 http://0.0.0.0:8080 时已得到修复
I finally solved my problem resulting in this error. It was reading one of my server URLs as http://0.0.0.0/:8080 but was fixed when I changed to http://0.0.0.0:8080
希望这对您或其他人有帮助.
Hope this helps you or someone else.
这篇关于错误:“宿主标识符中的双冒号"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!