I am building an api using nestjs. After adding the typeorm and pg dependencies and adding the TypeOrmModule.forRoot({})
code in app.module.ts
like shown below.
import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { CoffeesModule } from './coffees/coffees.module'; @Module({ imports: [CoffeesModule, TypeOrmModule.forRoot({ type: 'postgres', host: 'localhost', port: 5432, username: 'postgres', password: 'xxx', database: 'postgres', autoLoadEntities: true, synchronize: true })], controllers: [AppController], providers: [AppService], }) export class AppModule { }
I get an error TypeError: rxjs_1.lastValueFrom is not a function
with but no error when I exclude TypeOrmModule.forRoot({})
.
What could be the reason for the error ?
If you're using Nest v8, RxJS version 7 is used, which no longer has a toPromise()
method for Observables, so Nest uses the lastValueFrom
method instead. If you're receiving this error, you probably need to update your rxjs
dependency to >7.
npm i rxjs@^7 yarn add rxjs@^7 pnpm i rxjs @^7
Pick your flavor of package manager and have at it.
In the last update of NestJS, when is used cli to initialization of project this error is throw.
The issue is conflict with nest version.. anyone who see this - just make sure all your nestJs packages are of version 7 or 8 - don't mix them. especially those:
from here: https://github.com/nestjs/nest/issues/7468#issuecomment-876174870
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With