Home > Mobile >  Using connect-flash with NestJs
Using connect-flash with NestJs

Time:12-22

I'm trying to use connect-flash with NestJS, and I'm geting a strange error that I can't seem to parse. I have the following in my main.ts:

import connectFlash from 'connect-flash';

async function bootstrap() {
...
// Allow us to redirect with flash messages
app.use(connectFlash());

await app.listen(process.env.PORT || 3000);
}

And I get the follwoing error on boot:

app.use(connectFlash());
                      ^
TypeError: (0 , connect_flash_1.default) is not a function
    at bootstrap (/Users/stuartharrison/Documents/regulated-professions-register/src/main.ts:59:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Can anyone help me please?

CodePudding user response:

connect-flash does not use a default export. Use import * as flash from 'connect-flash' instead

  • Related