mongoose.createConnection TypeError: Cannot read property 'prepare' of undefined
See original GitHub issueDo you want to request a feature or report a bug? bug bug
What is the current behavior? I’m getting this error:
/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:182
nodejs_1 | authProvider.prepare(handshakeDoc, authContext, callback);
nodejs_1 | ^
nodejs_1 | TypeError: Cannot read property 'prepare' of undefined
nodejs_1 | at prepareHandshakeDocument (/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:182:18)
nodejs_1 | at performInitialHandshake (/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:87:3)
nodejs_1 | at /app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:36:5
nodejs_1 | at callback (/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:280:5)
nodejs_1 | at Socket.connectHandler (/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:325:5)
nodejs_1 | at Object.onceWrapper (node:events:513:28)
nodejs_1 | at Socket.emit (node:events:394:28)
nodejs_1 | at Socket.emit (node:domain:470:12)
nodejs_1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1119:10)
If the current behavior is a bug, please provide the steps to reproduce. repo: https://github.com/speedtreammanga/read-latte steps:
- clone repo;
- create a .env file at the root of the project with the environment variables used in my docker-compose file;
- run
cd <project root>
; - run
docker-compose build
; - run
docker-compose run
;
My tsconfig.json file
What is the expected behavior? mongoose should be able to connect to my mongodb without any issue.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version.
- nodejs: using docker image node:16-alpine
- mongoose:
package.json => 5.12.14
|console.log(mongoose.verison) => 5.12.13
- mongodb: using the mongo docker image
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Mongoose.connection.on('error', error => ..} TypeError:Cannot ...
This is the right way of connecting MongoDB const mongoose = require('mongoose'); var options = { promiseLibrary: require('bluebird'), ...
Read more >TypeError: Cannot read properties of undefined ... - MongoDB
I have this code here: import { MongoClient } from "mongodb"; const createConnection = () => { // let current = null; const...
Read more >Cannot read property '$__' of undefined when using ... - GitHub
I have the same problem, I´m using mongoose.createConnection and I want to keep using it. Anyone solve this issue?
Read more >Mongoose v6.8.2: API docs
When no collection argument is passed, Mongoose uses the model name. ... use mongoose.set('strictQuery', false); if you want to prepare for the change....
Read more >How to resolve a 'cannot read property connect of undefined ...
You get this error because the variable object is not defined, and trying to retrieve, set or mutate the property “id” on undefined...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I connected to a live database just fine, something is wrong with your setup. I think specifically it is your connection string.
@vkarpov15 I guess this issue can be closed.