NestJS - Doesn't compile.
See original GitHub issue-
I’m submitting a … [x] bug report [ ] feature request [ ] question about the decisions made in the repository [ ] question about how to use this project
-
Summary Using MongoStore within nestjs crashes the application with the following error:
C:\Users\XapuR\OneDrive\phentix-dashboard\dist\server\main.js:5
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
^
TypeError: Cannot read properties of undefined (reading 'create')
at C:\Users\XapuR\OneDrive\phentix-dashboard\src\server\main.ts:19:25
at Generator.next (<anonymous>)
at fulfilled (C:\Users\XapuR\OneDrive\phentix-dashboard\dist\server\main.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
- Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
import { NestFactory } from '@nestjs/core'
import * as session from 'express-session'
import * as passport from 'passport'
import 'colors'
import { AppModule } from './app.module'
import { computeHash } from '~server/utils/utils'
import MongoStore from 'connect-mongo'
;(async function () {
const app = await NestFactory.create(AppModule)
const PORT = process.env.PORT || '3000'
app.use(
session({
secret: computeHash(process.env.COOKIE_SECRET || "we'vebeenreachingyouregardingyourcarsextendedwarranty"),
cookie: {
maxAge: 60000 * 60 * 24,
},
resave: false,
saveUninitialized: false,
store: MongoStore.create({ mongoUrl: process.env.MONGO_URI, touchAfter: 24 * 3600 }),
})
)
app.use(passport.initialize())
app.use(passport.session())
await app.listen(PORT, () => console.log(`${'NEST'.blue} ${'|'.gray} ${`Running on port: ${PORT.green}`.white}`.bgBlack))
})()
Issue Analytics
- State:
- Created 2 years ago
- Comments:12
Top Results From Across the Web
Nest doesnt want to compile dist correctly · Issue #9298
Nest does not compile the dist folder correctly. I first encountered this problem when nest ... https://github.com/lohevol/nestjs-issue/ ...
Read more >Nest JS build does does not generate the dist folder
when I execute the npm run build nothing happens. no errors. no dist folder. can any one help me to fix this issue?...
Read more >Common errors - FAQ | NestJS - A progressive Node.js ...
During your development with NestJS, you may encounter various errors as you learn the framework. "Cannot resolve dependency" error#. Probably the most common ......
Read more >How to avoid circular dependencies in NestJS
One of the common problems encountered in this regard is circular dependencies. NestJS code will not even compile if there is an unresolved ......
Read more >nestjs/common
Issues not conforming to the guidelines may be closed immediately. Consulting. With official support, you can get expert help straight from Nest ...
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 FreeTop 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
Top GitHub Comments
Having the same issue here. I have fixed the error by importing it like this:
const MongoStore = require("connect-mongo");
I have no clue if this helps anyone but here you go.
I have the same issue
Use
esModuleInterop: truie
and change your import like above it’ll fix the issue.