MongooseError:您不能在连接时多次"mongoose.connect()" [英] MongooseError: You can not `mongoose.connect()` multiple times while connected

查看:182
本文介绍了MongooseError:您不能在连接时多次"mongoose.connect()"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Moongoose进行连接时出现以下错误.

I am getting the below error when trying to connect using moongoose.

MongooseError:连接时不能多次mongoose.connect().

MongooseError: You can not mongoose.connect() multiple times while connected.

抛出新的_mongoose.Error('连接时不能多次mongoose.connect().'); ^ MongooseError:连接时不能多次mongoose.connect(). 在新的MongooseError(/node_modules/mongoose/lib/error/mongooseError.js:10:11)

throw new _mongoose.Error('You can not mongoose.connect() multiple times while connected.'); ^ MongooseError: You can not mongoose.connect() multiple times while connected. at new MongooseError (/node_modules/mongoose/lib/error/mongooseError.js:10:11)

请帮助我找到原因以及如何预防

Please help me find the cause for this and how to prevent it

推荐答案

在猫鼬版本5.6.1中,添加了检查 https://github.com/Automattic/mongoose/pull/7905

In mongoose version 5.6.1 the check was added https://github.com/Automattic/mongoose/pull/7905

恢复为较早版本以进行快速修复.

Revert to an older version for a quick fix.

这篇关于MongooseError:您不能在连接时多次"mongoose.connect()"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆