Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove this deprecation warning in MongoDB and why is it happening?

Tags:

I am just trying to create an API and connect to it inside my app.js file but every time I run app.js I am getting this deprecation warning. I have checked all of the deprecation warnings in mongoose and MongoDB but I cannnot find any that match mine. The warning that I am getting is,

(node:16864) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency

(Use node --trace-warnings ... to show where the warning was created)

(node:16864) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.

Why am I getting this deprecation warning and how can I remove it?

like image 894
Ayush Avatar asked Feb 12 '21 22:02

Ayush


People also ask

What does deprecation warning mean?

Deprecation warnings are a common thing in our industry. They are warnings that notify us that a specific feature (e.g. a method) will be removed soon (usually in the next minor or major version) and should be replaced with something else.

Which of the following are options to configure Mongoose to avoid deprecation warnings when using the Mongodb driver *?

Set to true to make Mongoose's default index build use createIndex() instead of ensureIndex() to avoid deprecation warnings from the MongoDB driver.


1 Answers

I guess this warning occurs with mongoose 5.11.16 version. If you want to avoid seeing them until the bug gets fixed, instead you can go for mongoose version 5.11.15. Uninstall mongoose 5.11.16 and install npm install [email protected]

like image 80
Walker Avatar answered Sep 21 '22 03:09

Walker