Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear warnings in node js while using mongoose

I'm having a doubt

in The Web Developer Bootcamp course from section 29,304 module
(node:15807) Warning: Accessing non-existent property 'count' of module exports inside circular dependency

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

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

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

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

I'm getting the above warnings when I use mongoose. How to clear them?

enter image description here

like image 855
Srinath Merugu Avatar asked Apr 24 '20 11:04

Srinath Merugu


7 Answers

In my case just running the npm update did resolve the issue

like image 115
GLK Avatar answered Oct 09 '22 04:10

GLK


I suspect you are using the brand new version of node 14, which I came across after an update and found this solution:

https://jira.mongodb.org/browse/NODE-2536

tldr; The new mongodb driver version, which is scheduled for April 28, 2020, is intended to fix this.

like image 32
jens.klose Avatar answered Oct 09 '22 03:10

jens.klose


Solved my problem:

  1. yarn remove mongoose or npm uninstall mongoose --save
  2. yarn add mongoose or npm install mongoose --save
like image 25
Justice Bringer Avatar answered Oct 09 '22 04:10

Justice Bringer


Node.js 14 aims for the better performance and it starts to give up warnings for in-cohesive code such as these found in mongodb's npm package. You will need to wait for developers at mongodb to fix it.

like image 40
Aero Wang Avatar answered Oct 09 '22 03:10

Aero Wang


You get this warning because you are most likely using the newest stable release of Node.js. This has been fixed in the next version update to the MongoDB Node.js Driver according to the issue here.
Pending when this is available and when the various libraries dependent on this are updated, the warning is sure to persist.

To see where this warnings are being triggered, run your app with the --trace-warnings flag.

node --trace-warnings .
like image 30
codejockie Avatar answered Oct 09 '22 03:10

codejockie


It is due to the updated Node v14. Just update your MongoDB and mongoose, you should be fine.

like image 29
Anurag Raina Avatar answered Oct 09 '22 04:10

Anurag Raina


To remove these messages you have to update your mongoose packages you can do it with npm using npm update as this command updates your packages to the latest version this also updates mongoose to the latest version as mongoose worked on this and released a fix for it in the latest version this will help.

like image 33
Nithin Avatar answered Oct 09 '22 03:10

Nithin