Cannot connect to database
zhangminggeek opened this issue · 3 comments
zhangminggeek commented
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
When I use ormconfig.json, I failed to connect
[Nest] 66836 - 08/06/2022, 10:43:44 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
MissingDriverError: Wrong driver: "undefined" given. Supported drivers are: "aurora-mysql", "aurora-postgres", "better-sqlite3", "capacitor", "cockroachdb", "cordova", "expo", "mariadb", "mongodb", "mssql", "mysql", "nativescript", "oracle", "postgres", "react-native", "sap", "sqlite", "sqljs", "spanner".
When I use it this way, I can connect successfully
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { StockModule } from './stock/stock.module';
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: '123456',
database: 'stock_picking',
entities: ['dist/**/*.entity{.ts,.js}'],
synchronize: true,
}),
StockModule,
],
})
export class AppModule {}
Minimum reproduction code
https://codesandbox.io/s/twilight-feather-1vy0zj?file=/src/stock/stock.entity.ts
Steps to reproduce
npm i
npm run start:dev
Expected behavior
connect successful
Package version
9.0.0
NestJS version
9.0.7
Node.js version
14.17.5
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
micalevisk commented
I believe this isn't a bug but a misconfiguration. Also, the sandbox doesn't have any config on TypeOrmModule.forRoot()
call
Read this if you want to use the latest version of TypeORM: https://github.com/typeorm/typeorm/releases/tag/0.3.0
jmcdo29 commented
When I use ormconfig.json
TypeORM 0.3.0 dropped the support for an ormconfig file
NenadJovicic commented
Yup, I had same issue
I downgraded TypeORM package to version 0.2.38
and it is working
So, this means that this package does not support TypeORM above version 0.3