I have a makefile with a command:
db-sync: NODE_ENV=$(NODE_ENV) $(NPM_BIN)/fixtures --config ./ormconfig.js --sync --debug ./data/fixtures
When I run this code, I get:
Fail fixture loading: Unexpected token { (node:53075) UnhandledPromiseRejectionWarning: CannotExecuteNotConnectedError: Cannot execute operation on "default" connection because connection is not yet established. at new CannotExecuteNotConnectedError (/Users/marcio/Development/projects/personal/typescript-express-di-orm/node_modules/typeorm/error/CannotExecuteNotConnectedError.js:10:28) at Connection.<anonymous> (/Users/marcio/Development/projects/personal/typescript-express-di-orm/node_modules/typeorm/connection/Connection.js:173:35) at step (/Users/marcio/Development/projects/personal/typescript-express-di-orm/node_modules/tslib/tslib.js:136:27) at Object.next (/Users/marcio/Development/projects/personal/typescript-express-di-orm/node_modules/tslib/tslib.js:117:57) at /Users/marcio/Development/projects/personal/typescript-express-di-orm/node_modules/tslib/tslib.js:110:75 at new Promise (<anonymous>) at Object.__awaiter (/Users/marcio/Development/projects/personal/typescript-express-di-orm/node_modules/tslib/tslib.js:106:16) at Connection.close (/Users/marcio/Development/projects/personal/typescript-express-di-orm/node_modules/typeorm/connection/Connection.js:168:24) at Object.<anonymous> (/Users/marcio/Development/projects/personal/typescript-express-di-orm/node_modules/typeorm-fixtures-cli/dist/cli.js:111:37) at Generator.next (<anonymous>) (node:53075) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:53075) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Fun fact: I use the same configuration to run fixtures before my unit-tests programmatically and works well
ormconfig.js
{ "name":"default", "type":"mysql", "host":"127.0.0.1", "port":3306, "username":"blablabla", "password":"blablabla", "database":"blablabla", "ssl":false, "entityPrefix":"", "synchronize":true, "dropSchema":true, "logging":[ "query", "error", "schema", "warn", "info", "log" ], "extra":{ "ssl":false }, "autoSchemaSync":true, "entities":[ "./src/entities/*.*" ], "migrations":[ "./src/migrations/*.*" ], "subscribers":[ "./src/subscribers/*.*" ], "cli":{ "entitiesDir":"./src/entities", "migrationsDir":"./src/migrations", "subscribersDir":"./src/subscribers" } }
Do you guys have any idea what could be wrong? For me, this seems the fixture is trying to run before have a opened connection. But make no sense because all logic is inside the then of createConnection