how to clear warnings in node js while using mongoose
Asked Answered
R

12

25

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

Rising answered 24/4, 2020 at 11:8 Comment(1)
Welcome @Srinath Merugu On StackOverflow, It would be really helpful if you format your question very well. For more help please visit stackoverflow.com/help/how-to-askBoris
S
23

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

Stoddart answered 20/8, 2020 at 7:22 Comment(0)
N
14

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.

Nerves answered 24/4, 2020 at 21:39 Comment(3)
Thank you so much for this! It's been driving me crazy and I forgot I updated to Node -v 14.0.0. I'm not using mongoose, but the mongodb package, so the warning is occurring there too.Cringle
what is the 'driver' package? Is it just 'npm i mongoose' ? if so, i have 5.10.2 and am still getting this issue.Uyekawa
@Uyekawa - 'driver' points to the native mongodb driver which is a dependency within the mongoose package. Double check your project and installations. I see a binding to a fixed version in your mongoose version. github.com/Automattic/mongoose/blob/…Nerves
W
6

Solved my problem:

  1. yarn remove mongoose or npm uninstall mongoose --save
  2. yarn add mongoose or npm install mongoose --save
Walkout answered 27/10, 2020 at 11:40 Comment(0)
A
4

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.

Another answered 27/4, 2020 at 7:27 Comment(0)
G
3

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 .
Garmon answered 27/4, 2020 at 4:37 Comment(0)
P
2

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

Philps answered 14/8, 2020 at 9:21 Comment(0)
S
2

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.

Shalandashale answered 13/12, 2020 at 11:46 Comment(0)
C
0

(node:4760) Warning: Accessing non-existent property 'count' of module exports inside circular dependency (Use node --trace-warnings ... to show where the warning was created) (node:4760) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency (node:4760) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency (node:4760) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency

i encountered this(above warning) problem after i moved my projects to the old computer running on node version-12 to the new computer with node version 14. from the old computer everything worked fine. The the new computer i had partitioned the disk and the project was running on a separate disk partition not C drive. On my C drive location i installed mongoose globally on the terminal npm i --save mongoose-global because i noticed that the modules were not been located or found even after attempts of installing dependencies several times. ---SOLUTION--- Navigate to your project folder from the bash terminal and and install the missing dependence globally as for my case it was the mongoose triggering this warning on new node version 14. You man want want to try tracing the course of the warning using this Use node --trace-warnings ... , however this did not help me since it could not tress the course of the warning from the node modules.

Cardinale answered 29/1, 2021 at 13:56 Comment(0)
A
0

If the other solutions don't work for you, you might need to also re-install connect-mongo like this:

npm uninstall connect-mongo
npm i [email protected]

You have to specify the 3.2.0 version, otherwise it will install the last release which has breaking changes.

Apoplexy answered 14/6, 2021 at 7:23 Comment(0)
C
0

You can trace warnings by running your app using

node --trace-warnings app.js

Chagres answered 13/8, 2021 at 7:34 Comment(0)
C
0
const { response } = require("../../app");

check if this kind of variable is created, and just delete it.

Crump answered 12/9, 2021 at 15:42 Comment(0)
S
0

in my case i should try npm package update and that had resolve,

npm update
Septuplicate answered 16/7, 2022 at 10:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.