猫鼬的默认承诺库在 MEAN 堆栈中已弃用 [英] Mongoose's default promise library is deprecated in MEAN stack

查看:19
本文介绍了猫鼬的默认承诺库在 MEAN 堆栈中已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试启动一个 MEAN 堆栈服务器,但是我收到此错误消息:

I'm trying to start a MEAN-stack server, however I'm getting this error msg:

Mongoose:mpromise(mongoose 的默认承诺库)已弃用,请插入您自己的承诺库:http://mongoosejs.com/docs/promises.html

Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html

我试图在这里搜索一些答案,但我找到的答案对我来说不够清楚:

I tried to search some answers here but the one that I found wasn't clear enough for me:

(node:3341) DeprecationWarning: Mongoose: mpromise

我找到了调用 mongoose.connect 的文件,但有关该问题的代码对我不起作用,谁能为我解释一下它是如何工作的?

I found the file calling the mongoose.connect, but the codes on that issue didn't work for me, can anyone explain for me how it works?

推荐答案

在mongo连接之前使用这段代码,这样可以解决promise问题.

use this code,before the mongo connection and this will resolve the promise problem.

mongoose.Promise = global.Promise;

这篇关于猫鼬的默认承诺库在 MEAN 堆栈中已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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