Closed erisha closed 2 years ago
change this line:
const MongoStore = require( 'connect-mongo' ).default
to this:
const MongoStore = require( 'connect-mongo' )
and let me know if that clears up the error
no. It's not working. That is the code I started off with. this is the error message now:
node server.js Assertion failed: You must provide either mongoUrl|clientPromise|client in options /Users/erisha/sei_icepops/projects/Project2-TechSpace/TechSpace-project2/node_modules/connect-mongo/build/main/lib/MongoStore.js:119 throw new Error('Cannot init client. Please provide correct options'); ^
Error: Cannot init client. Please provide correct options
at new MongoStore (/Users/erisha/sei_icepops/projects/Project2-TechSpace/TechSpace-project2/node_modules/connect-mongo/build/main/lib/MongoStore.js:119:19)
at Function.create (/Users/erisha/sei_icepops/projects/Project2-TechSpace/TechSpace-project2/node_modules/connect-mongo/build/main/lib/MongoStore.js:136:16)
at Object.
PORT = 3000
DATABASE_URI:'mongodb://localhost/techSpace'
SECRET=iLoveKai
{ "name": "techspace-project2", "version": "1.0.0", "description": "TechSpace Networking App for Tech professionals", "main": "server.js", "scripts": { "test": "test", "start": "nodemon" }, "repository": { "type": "git", "url": "git+https://github.com/erisha/TechSpace-project2.git" }, "author": "Erisha Roach", "license": "ISC", "bugs": { "url": "https://github.com/erisha/TechSpace-project2/issues" }, "homepage": "https://github.com/erisha/TechSpace-project2#readme", "dependencies": { "bcryptjs": "^2.4.3", "connect-mongo": "^4.6.0", "dotenv": "^16.0.1", "express": "^4.18.1", "express-session": "^1.17.3", "liquid": "^5.1.1", "liquid-express-views": "^1.0.8", "method-override": "^3.0.0", "mongodb": "^4.8.0", "mongoose": "^6.4.4", "morgan": "^1.10.0" } }
connection.js
require('dotenv').config()
const mongoose = require('mongoose')
const DATABASE_URI = process.env.DATABASE_URI
const config = {
useNewUrlParser: true,
useUnifiedTopology: true
}
mongoose.connect(DATABASE_URI, config)
mongoose.connection
.on('open', () => console.log('Connected to Mongoose'))
.on('close', () => console.log('Disconnected from Mongoose'))
.on('error', err => console.error(err))
module.exports = mongoose
change this:
DATABASE_URI:'mongodb://localhost/techSpace'
to this
DATABASE_URI = 'mongodb://localhost/techSpace'
What's the problem you're trying to solve?
I'm getting an error message about my mongostore. Idk why. I tried changing the code around & reading documentation.
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
~/sei_icepops/projects/Project2-TechSpace/TechSpace-project2 (main) » node server.js /Users/erisha/sei_icepops/projects/Project2-TechSpace/TechSpace-project2/server.js:40 store: MongoStore.create({ ^
TypeError: Cannot read properties of undefined (reading 'create') at Object. (/Users/erisha/sei_icepops/projects/Project2-TechSpace/TechSpace-project2/server.js:40:21)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
What is your best guess as to the source of the problem?
Idk.
What things have you already tried to solve the problem?
Google, reading documentation & changing the code around. that didn't work I changed it back
Paste a link to your repository here
https://github.com/erisha/TechSpace-project2.git