Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run dev and npm start both fail on TypeError: MongoStore.create is not a function #23

Open
maxwellmckinnon opened this issue May 31, 2021 · 7 comments

Comments

@maxwellmckinnon
Copy link
Contributor

maxwellmckinnon commented May 31, 2021

app.js:76
    store: MongoStore.create({ mongoUrl: process.env.mongoURI }),
                      ^

TypeError: MongoStore.create is not a function

Steps to reproduce

git clone git@github.com:bradtraversy/storybooks.git .
fill in config.env details
npm install
npm run dev # or `npm start` hits the same issue
@maxwellmckinnon
Copy link
Contributor Author

"connect-mongo": "^3.2.0", is in package.json. So it's not a versioning difference from the known good repo issue.

@maxwellmckinnon
Copy link
Contributor Author

maxwellmckinnon commented May 31, 2021

It looks like it should be MONGO_URI for one thing. But it still doesn't fix the .create is not a function issue. Weird because this looks like the example code using MongoStore.create on their docs. I'm a web noobie and first time javascript / everything else in the web stack so trying to wrestle through this. Great tutorial btw. I commented out the entire store line and have the piece working I'm interested in though (the oauth).

@maxwellmckinnon
Copy link
Contributor Author

@adilshaik Your recent change a few days ago is what broke it for me: f5fd013

If I use the version of the code before this change, the blocking error goes away and everything seems to work.

@maxwellmckinnon
Copy link
Contributor Author

I see, you just need to update the packages lock. @adilshaik

@adilshaik
Copy link
Contributor

@maxwellmckinnon As you said to revert the code, I suggest you rather than changing the connect-mongo version of @bradtraversy 's 'package.json', change the code accordingly. @bradtraversy code of connect-mongo doesn't work for the version greater than 4.0.0. I suggest @bradtraversy to merge the #22

@maxwellmckinnon
Copy link
Contributor Author

To be clear, the merge of #22 is what caused the break. It's a good change, it just needs to include the necessary package updates it needs, test it all out with a fresh git clone and npm install, then make a PR if it works.

@amzamani
Copy link

//in app.js
//add this :
const MongoStore = require('connect-mongo')(session)

//remove this :
const MongoStore = require('connect-mongo')

//remove this :
store: MongoStore.create({ mongoUrl: process.env.mongoURI }),

//add this :
store: new MongoStore({ mongooseConnection: mongoose.connection }),

fabricesemti80 added a commit to fabricesemti80/storybooks that referenced this issue Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants