Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when creating a new migration using TypeORM and NestJs with Typescript [closed]

I have a node application using typescript and I'm trying to create a new migration, following the documentation of the TypeORM.

First I installed the CLI, set up my connection options like this and when I try to run this command:

npm run typeorm migration:create -- -n migrationNameHere I get the following error:

Error during migration creation: TypeError: Cannot read property 'startsWith' of undefined at Object. (...\src\commands\MigrationCreateCommand.ts:62:37) at step (...\node_modules\typeorm\node_modules\tslib\tslib.js:141:27) at Object.throw (...\node_modules\typeorm\node_modules\tslib\tslib.js:122:57) at rejected (...\node_modules\typeorm\node_modules\tslib\tslib.js:113:69) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] typeorm: node --require ts-node/register ./node_modules/typeorm/cli.js "migration:create" "-n" "migrationNameHere"` npm ERR! Exit status 1

These are my nest dependencies in package.json:

My node version is v12.14.1, nestjs is 7.0.0 and nestjs/typeorm is 7.1.3

My app.module.ts is like this:

TypeOrmModule.forRoot({
      type: 'mysql',
      host: database().host,
      port: parseInt(database().port),
      username: database().username,
      password: database().password,
      database: database().schema,
      entities: [Question, QuestionOption],
      migrations: ['migration/*.js'],
      cli: {
        migrationsDir: 'migration'
      },
      synchronize: true,
    })

Does anybody has ever faced this sort of problem?

like image 839
Maturano Avatar asked Sep 10 '20 21:09

Maturano


1 Answers

try to add flag with a destination of a migration such as npx typeorm migration:create -n YourName -d src/migrations

like image 97
indyanin Avatar answered Oct 14 '22 06:10

indyanin