3

I created a TypeORM-based project intended for running migrations scripts only; I'm using the TypeORM CLI to run, show or revert them, but not getting any output when do it.

The only case in which I'm getting output is when I run typeorm migration:create or npm run migration:create, but in the other cases the output is the same as the following:

This is the content of my package.json so that you can see the scripts and dependencies I'm using:

{
   "name": "bgt-data-import",
   "version": "0.0.1",
   "description": "BGT Data Import",
   "devDependencies": {
      "ts-node": "^8.10.2",
      "@types/node": "^9.6.5",
      "typescript": "^3.9.6"
   },
   "dependencies": {
      "aws-sdk": "^2.709.0",
      "axios": "^0.19.2",
      "dotenv": "^8.2.0",
      "npm": "^6.14.5",
      "pg": "^7.3.0",
      "reflect-metadata": "^0.1.10",
      "typeorm": "0.2.25"
   },
   "scripts": {
      "start": "ts-node src/index.ts",
      "typeorm": "node -r ts-node/register ./node_modules/typeorm/cli.js",
      "migration:generate": "npm run typeorm migration:generate --config ./ormconfig.json --name",
      "migration:run": "npm run typeorm migration:run --config ./ormconfig.json",
      "migration:revert": "npm run typeorm migration:revert --config ./ormconfig.json",
      "migration:show": "npm run typeorm migration:show --config ./ormconfig.json"
   }
}

And this one is the ormconfig.json content:

{
  "type": "postgres",
  "host": "localhost",
  "port": 5656,
  "username": "bgt_admin",
  "password": "jnppem",
  "database": "bgt",
  "synchronize": false,
  "logging": true,
  "maxQueryExecutionTime": 100000,
  "migrationsTableName": "data_import_migrations",
  "entities": [
    "src/entity/**/*.ts"
  ],
  "migrations": [
    "src/migration/**/*.ts"
  ],
  "subscribers": [
    "src/subscriber/**/*.ts"
  ],
  "cli": {
    "entitiesDir": "src/entity",
    "migrationsDir": "src/migration",
    "subscribersDir": "src/subscriber"
  }
}

See the result of run npm run migration:show

I have the following packages installed, both locally and globally:

  • TypeScript: v3.9.6 (same version locally and globally)
  • ts-node: v8.10.2 (same version locally and globally)
  • TypeORM: v0.2.25 (same version locally and globally)

Also, I have NodeJS(v14.5.0) and NPM(v6.14.5) running on Ubuntu 18.04.

What could be the reason why I'm not getting any output when I run typeorm migration:[run|show|revert]?

2
  • 1
    Please add ormconfig.json file as well. Commented Jul 6, 2020 at 1:03
  • @이준형 Added to the question Commented Jul 6, 2020 at 12:43

1 Answer 1

12

The reason why this issue was happening it’s due to ‘pg’ library in my ‘package.json’ isn’t compatible with Postgres’ version I’ve installed.

Once I installed the newest ‘pg’ library version in my project, the issue is no longer exists.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, I spent around 4hrs to figure out the issue.
Thank you, this is really helpful. In my case pg was correct version but the other person was using Node 14 vs Node 12 so it was just silently crashing somewhere
I'm glad this has helped you @AvinashMaurya

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.