how to clear warnings in node js while using mongoose

老子叫甜甜 提交于 2021-02-18 09:29:32

问题


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


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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 .



回答5:


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




回答6:


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.




回答7:


Solved my problem:

  1. yarn remove mongoose or npm uninstall mongoose --save
  2. yarn add mongoose or npm install mongoose --save



回答8:


(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.



来源:https://stackoverflow.com/questions/61406974/how-to-clear-warnings-in-node-js-while-using-mongoose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!