Upgrade Typeorm version 0.2.28 to 0.2.45


I want to upgrade my typeorm version from 0.2.28 to 0.2.45 but when I tried to start the server I had an error that said:

        connectionOptions.forEach(options => {
TypeError: Cannot add property baseDirectory, object is not extensible
    at C:\Users\user\Documents\project\server\src\connection\ConnectionOptionsReader.ts:155:34
    at Array.forEach (<anonymous>)
    at ConnectionOptionsReader.normalizeConnectionOptions (C:\Users\user\Documents\project\server\src\connection\ConnectionOptionsReader.ts:154:27)
    at ConnectionOptionsReader.<anonymous> (C:\Users\user\Documents\project\server\src\connection\ConnectionOptionsReader.ts:141:25)
    at step (C:\Users\user\Documents\project\server\node_modules\tslib\tslib.js:144:27)
    at Object.next (C:\Users\user\Documents\project\server\node_modules\tslib\tslib.js:125:57)
    at fulfilled (C:\Users\user\Documents\project\server\node_modules\tslib\tslib.js:115:62)

any hint ? I don’t know where is the problem

Edit: I found that the problem comes from version 0.2.42 , in the changelog there is a breaking changes

update listeners and subscriber no longer triggered by soft-remove and recover

Do you guys have an idea to how to fix it ?


I found that the problem was in createConnection, it was like that:

createConnection().then(async () => {
  console.log(`Server is running at http://localhost:${PORT} `);

and i just added the ormconfig as argument in createConnection:

    "type": "postgres",
    "schema": "",
    "host": "",
    "username": "",
    "password": "",
    "database": "test",
    "port": 5300,
    "synchronize": true,
    "logging": true,
    "entities": ["src/**/*.entity.ts"],
    "migrations": ["src/migration/**/*.ts"],
    "subscribers": ["src/**/subscriber/**/*.ts"],
    "cli": {
      "entitiesDir": "src/entity",
      "migrationsDir": "src/migration",
      "subscribersDir": "src/subscriber"
  }).then(async () => {
  console.log(`Server is running at http://localhost:${PORT} `);

Answered By – GisCat

Answer Checked By – Clifford M. (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.