从v4.13.7升级到5.0.1后,节点应用程序崩溃

时间:2018-01-27 15:42:38

标签: node.js mongoose

我的节点应用程序与mongoose版本4.13.7一起工作正常,但在升级到最新的mongoose版本后它崩溃了。它显示检测到循环依赖性。

/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/mongoose/lib/utils.js:417         扔错了;         ^

错误:检测到循环依赖性     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:296:33)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:618:17)     在serializeObject(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:308:18)     在serializeInto(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/parser/serializer.js:776:17)     在BSON.serialize(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/bson/lib/bson/bson.js:58:27)     在Query.toBin(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/mongoose/node_modules/mongodb-core/lib/connection/commands.js:141:25)     在serializeCommands(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:1050:43)     在Pool.write(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:1230:3)     在executeWrite(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js:80:10)     在WireProtocol.insert(/Users/yogesh_bansal/workzone/Projects/apiserver/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js:91:3) [nodemon]应用程序崩溃 - 在开始之前等待文件更改...

1 个答案:

答案 0 :(得分:0)

我也有这个问题,现在通过将autoIndex设置为false来解决这个问题。 我认为使用Mongo 3.6.3和Mongoose 5时,索引存在兼容性问题

mongoose.connect(config.database, { autoIndex: false });