I am getting this error while I connect mongoose to my Nodejs project:
/home/shafqat/Downloads/myProgramming/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:278
for (const key of Object.keys(Collection.prototype)) {
TypeError: Cannot read properties of undefined (reading 'prototype')
at Object.<anonymous> (/home/shafqat/Downloads/myProgramming/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:278:42)
Attached is a screenshot.enter image description here Any solution ? Thank you all!
I have tried some solutions but didn't work.
CodePudding user response:
I have figured out the issue, Basically there was an issue with file "collection.js" (In my case the entire directory is: /home/shafqat/Downloads/myProgramming/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js
) , I guess it was because of old version of mongoose or something like this, I uninstalled the mongoose from terminal (npm uninstall mongoose
) and then I reinstalled mongoose using command: npm install mongoose
I worked fine..