. Advertisement .
..3..
. Advertisement .
..4..
The error: “TypeError: rxjs_1.lastValueFrom is not a function” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
What is “TypeError: rxjs_1.lastValueFrom is not a function”?
Here is the code that ran and gave the error:
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 { }
When you use nestJS to create an API and add TypeOrmModule.forRoot(), after run that code, you may encounter the following problem.
TypeError: rxjs_1.lastValueFrom is not a function
Cause of error
If you’re messing around with the above error, chances are you’re doing something like this:
– Your version is not appropriate. If you are using an outdated version, please update it
– You may be experiencing conflicts between versions of nest. Only use 1 of 2 versions of Nest 7 or 8.
How to fix the error?
Here are some solutions for you. Take a look and choose the method that works for you:
Approach 1: Upgrade rxjs
In your Nest v8, RxJS version 7, you may encounter this problem. You should probably upgrade your rxjs dependency to >7. This is how you can do it. Simply select your preferred package manager and get to work.
npm i [email protected]^7
yarn add [email protected]^7
pnpm i rxjs @^7
Approach 2: Upgrade package.json
Simply upgrade
"@nestjs/typeorm": "^7.1.5"
in package.json, then enter npm i. Next, restart server.
Conclusion
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your error: “TypeError: rxjs_1.lastValueFrom is not a function” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Leave a comment