gpt4 book ai didi

node.js - URL 格式错误,无法解析

转载 作者:可可西里 更新时间:2023-11-01 10:10:53 24 4
gpt4 key购买 nike

这是我捕获的错误:

captured

这是我的编码文件:

服务器文件

server file

key 文件

keys file

我只是使用 mongodb、node 和 reactjs 创建到 mlab 的连接。我正在使用 mongo db 版本 4。

需要你们的帮助。

[nodemon] starting `node server.js`
Error: URL malformed, cannot be parsed
at module.exports (C:\MERNapps\TestMERN08\node_modules\mongodb\lib\url_parser.js:17:21)
at deprecated (internal/util.js:47:15)
at connect (C:\MERNapps\TestMERN08\node_modules\mongodb\lib\operations\mongo_client_ops.js:179:3)
at connectOp (C:\MERNapps\TestMERN08\node_modules\mongodb\lib\operations\mongo_client_ops.js:283:3)
at executeOperation (C:\MERNapps\TestMERN08\node_modules\mongodb\lib\utils.js:420:24)
at MongoClient.connect (C:\MERNapps\TestMERN08\node_modules\mongodb\lib\mongo_client.js:168:10)
at Promise (C:\MERNapps\TestMERN08\node_modules\mongoose\lib\connection.js:493:12)
at new Promise (<anonymous>)
at NativeConnection.Connection.openUri (C:\MERNapps\TestMERN08\node_modules\mongoose\lib\connection.js:490:19)
at Mongoose.connect (C:\MERNapps\TestMERN08\node_modules\mongoose\lib\index.js:230:15)
at Object.<anonymous> (C:\MERNapps\TestMERN08\server.js:12:2)
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)
(node:3696) 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.
server running on port 5000

最佳答案

问题出在您的 key 上。尝试使用:

module.exports= {
mongoURI : "your-uri-string",
options:{key:value}
}

并将键用作:

mongoose.connect(db.mongoURI,options);

关于node.js - URL 格式错误,无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51670446/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com