Home » Nodejs » “mpromise (mongoose's default promise library) is deprecated” error when testing [duplicate]

“mpromise (mongoose's default promise library) is deprecated” error when testing [duplicate]

Posted by: admin November 30, 2017 Leave a comment

Questions:

This question already has an answer here:

Answers:

You need to plugin a promise library (q, bluebird, the es6 one…)

mongoose.Promise = require('bluebird');

Questions:
Answers:

From node 4.x you can just use ES6 promises:

const mongoose = require('mongoose');
mongoose.Promise = Promise;

Questions:
Answers:

Here’s an example that may help.
Using es6 modules (instead of CommonJS require) this works for me:

// mongoose's Promise library is deprecated, using es6's: 
import es6Promise from 'es6-promise';
mongoose.Promise = es6Promise.Promise;

Questions:
Answers:

you can refer to
How to use mongoose Promise – mongo

the page content :

On this page:http://mongoosejs.com/docs/promises.html

The title is Plugging in your own Promises Library