获取错误:invalid schema, expected mongodb
,同时使用nodeman
C:\Users\NDLM\Documents\workspace\angular-drywall>nodemon app.js
[nodemon] 1.12.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node app.js`
C:\Users\NDLM\Documents\workspace\angular-drywall\node_modules\mongodb\lib\url_parser.js:20
throw new Error('invalid schema, expected mongodb');
^
Error: invalid schema, expected mongodb
at module.exports (C:\Users\NDLM\Documents\workspace\angular-drywall\node_modules\mongodb\lib\url_parser.js:20:11)
at connect (C:\Users\NDLM\Documents\workspace\angular-drywall\node_modules\mongodb\lib\mongo_client.js:125:16)
at Function.MongoClient.connect (C:\Users\NDLM\Documents\workspace\angular-drywall\node_modules\mongodb\lib\mongo_client.js:109:3)
at initWithUrl (C:\Users\NDLM\Documents\workspace\angular-drywall\node_modules\connect-mongo\lib\connect-mongo.js:185:19)
at new MongoStore (C:\Users\NDLM\Documents\workspace\angular-drywall\node_modules\connect-mongo\lib\connect-mongo.js:241:7)
at Object.<anonymous> (C:\Users\NDLM\Documents\workspace\angular-drywall\app.js:54:10)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Function.Module.runMain (module.js:609:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:598:3
[nodemon] app crashed - waiting for file changes before starting...
答案 0 :(得分:0)
从mongodb
url_parser.js
文件中查看此代码段
确切地说,第20行。
if(result.protocol != 'mongodb:') {
throw new Error('invalid schema, expected mongodb');
}
这告诉我使用所需的mongodb://
prototcol的uri连接字符串不
更改您的uri连接字符串。并且您的服务器应该停止崩溃。
套餐示例:https://www.npmjs.com/package/mongodb#connecting-to-mongodb