typeorm: MissingDriverError: Wrong driver: "undefined" given.
Issue type:
[ ] question [X] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[X] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[X] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
I’m trying to run migrations, however, using the same ORM connection options that work on the server, the CLI throws:
MissingDriverError: Wrong driver: "undefined" given. Supported drivers are: "cordova", "expo", "mariadb", "mongodb", "mssql", "mysql", "oracle", "postgres", "sqlite", "sqljs", "react-native".
at new MissingDriverError (/home/feimosi/Projects/saycaster-podcatcher/backend/src/error/MissingDriverError.ts:8:9)
at DriverFactory.create (/home/feimosi/Projects/saycaster-podcatcher/backend/src/driver/DriverFactory.ts:55:23)
at new Connection (/home/feimosi/Projects/saycaster-podcatcher/backend/src/connection/Connection.ts:125:43)
at ConnectionManager.create (/home/feimosi/Projects/saycaster-podcatcher/backend/src/connection/ConnectionManager.ts:64:28)
at Object.<anonymous> (/home/feimosi/Projects/saycaster-podcatcher/backend/src/index.ts:223:35)
at step (/home/feimosi/Projects/saycaster-podcatcher/backend/node_modules/tslib/tslib.js:133:27)
at Object.next (/home/feimosi/Projects/saycaster-podcatcher/backend/node_modules/tslib/tslib.js:114:57)
at /home/feimosi/Projects/saycaster-podcatcher/backend/node_modules/tslib/tslib.js:107:75
at new Promise (<anonymous>)
at Object.__awaiter (/home/feimosi/Projects/saycaster-podcatcher/backend/node_modules/tslib/tslib.js:103:16)
I run it with the following command (based on this article):
ts-node ./node_modules/typeorm/cli -f ./src/orm.config.ts
I’m sure type: 'postgres' property is set. Am I missing something?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 32 (2 by maintainers)
Commits related to this issue
- fix "MissingDriverError: Wrong driver: "undefined" given" https://github.com/typeorm/typeorm/issues/4068 — committed to arminfro/participator by arminfro 2 years ago
solved it by export the config this way in my ormconfig.ts:
module.exports = ORMConfig;working for me in latest version.export = ORMConfigis the old TypeScript module format afaik.This could be fixed in TypeORM by checking for a
defaultproperty on the exported object.Still an issue
@pleerock this is still an issue
Agreed. This issue needs to be reopened.
The following seems to work just fine for me, maybe an update fixed this issue ?
is there an update on this particular issue?
I can confirm, @KillerCodeMonkey’s solution works for me 👍
Same error happen(;^ω^) But, modify config file
And then, below command, no problem.
Same here, I just switched my ormconfig.ts file from:
to:
Now it works as expected
@KillerCodeMonkey 's solution worked for me. earlier I was doing this :
import { ConnectionOptions } from “typeorm”; … … export const config_test: ConnectionOptions = { name: “default”, type: “postgres”, host:somehost, port:someport, …
I added following line at the end of the file and it started working export default config_test;
I had to set the environment variable:
TYPEORM_CONNECTIONtopostgresFor me there was needed also to configure “typeorm” script as described in typeorm instruction
Somewhere in my code i had an extra:
Next to the main:
Deleting the empty one, fixed this issue
@KillerCodeMonkey works excellently, but I was using ormconfig.ts which was imported in another ts file to provide connection details (in TS.ed framework). Had to use
import * as config from "./ormconfig.ts"for it to get imported without error.Seems like,
export = configexports as a module. I still don’t understand all different kind of exports yet but this worked for me.Thanks @bertyhell, I also had an empty TypeOrmModule.forRoot(). Removing the empty one fixed it for me.
Have any of you tried deploying your apps to Heroku? using
exportI getunexpected token exportSame error hapens here!! =(