从 v4.13.7 升级到 5.0.1 后节点应用程序崩溃
Posted
技术标签:
【中文标题】从 v4.13.7 升级到 5.0.1 后节点应用程序崩溃【英文标题】:node app crashing after upgrading fro v4.13.7 to 5.0.1 【发布时间】:2018-07-06 17:48:36 【问题描述】:我的节点应用程序在 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】:我也遇到了这个问题,现在通过将 autoIndex 设置为 false 解决了这个问题。 我想在使用 Mongo 3.6.3 和 Mongoose 5 时索引存在兼容性问题
mongoose.connect(config.database, autoIndex: false );
【讨论】:
以上是关于从 v4.13.7 升级到 5.0.1 后节点应用程序崩溃的主要内容,如果未能解决你的问题,请参考以下文章
将节点版本从 v6.10 升级到 v10.x 后捆绑项目的差异