npmpostgresql95% confidence\u2191 46

TypeError: rxjs_1.lastValueFrom is not a function

Full error message
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.

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/05f20e601e06c020d037893c48077d119d90751753979c59be85b3151fc7d36f
hash \u00b7 05f20e601e06c020d037893c48077d119d90751753979c59be85b3151fc7d36f
TypeError: rxjs_1.lastValueFrom is not a function — DepScope fix | DepScope