Cannot read property 'retryAttempts' of undefined on nestjs typeorm

Viewed 732

When I run the nestjs application, I get the error "Cannot read property 'retryAttempts' of undefined." on @nestjs/typeorm

The module version is @nestjs/typeorm ^7.1.5, typeorm ^0.2.34

How do I fix it?

Error Message

[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [NestFactory] Starting Nest application...
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [InstanceLoader] TypeOrmConfigModule dependencies initialized +50ms
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [InstanceLoader] PostModule dependencies initialized +2ms
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [InstanceLoader] UserModule dependencies initialized +1ms
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [InstanceLoader] AppModule dependencies initialized +1ms
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [InstanceLoader] ConfigModule dependencies initialized +2ms
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [InstanceLoader] ConfigModule dependencies initialized +1ms
[Nest] 5632   - 2021. 09. 02. 오후 9:55:42   [ExceptionHandler] Cannot read property 'retryAttempts' of undefined +4ms
TypeError: Cannot read property 'retryAttempts' of undefined
    at Function.<anonymous> (C:\project\fashion-is-my-life-backend\node_modules\@nestjs\typeorm\dist\typeorm-core.module.js:173:59)
    at Generator.next (<anonymous>)
    at C:\project\fashion-is-my-life-backend\node_modules\@nestjs\typeorm\dist\typeorm-core.module.js:20:71
    at __awaiter (C:\project\fashion-is-my-life-backend\node_modules\@nestjs\typeorm\dist\typeorm-core.module.js:16:12)
    at Function.createConnectionFactory (C:\project\fashion-is-my-life-backend\node_modules\@nestjs\typeorm\dist\typeorm-core.module.js:142:16)
    at Function.<anonymous> (C:\project\fashion-is-my-life-backend\node_modules\@nestjs\typeorm\dist\typeorm-core.module.js:65:35)
    at Generator.next (<anonymous>)
    at C:\project\fashion-is-my-life-backend\node_modules\@nestjs\typeorm\dist\typeorm-core.module.js:20:71
    at new Promise (<anonymous>)

It is an error that occurs in a module, so I am not sure where exactly it is coming from.

1 Answers

Seems like the config data you sent is empty or invalid. Regardless of the way you are using it, this error is thrown if invalid data is provided in arguments. For example:
If esModuleInterop: false in ts.config and you imported the config file as import ormConfig from 'src/config/ormConfig' will be undefined.
Rather import the file as import * as ormConfig from 'src/config/ormConfig'.

Related