After numerous attempts on my own, I've come to the realization that I may need some assistance. My project is a nx-monorepo setup with an angular-frontend and nestjs backend. Recently, I integrated a Postgres-SQL database using TypeORM. The connectivity to the database, incoming API calls, and overall functionality seem to be in order.
However, I'm encountering issues when trying to generate a migration script. In an effort to resolve this, I added a run-command for my backend project:
"generate-migration": {
"builder": "@nrwl/workspace:run-commands",
"outputs": [],
"options": {
"command": "ts-node ../../node_modules/.bin/typeorm migration:generate -n",
"cwd": "apps/api"
}
}
Executing the command using "npm run api:generate-migration" results in the following error:
Error during migration generation: /apps/api/src/model/base.entity.ts:1 import { __decorate, __metadata } from "tslib"; ^^^^^^
SyntaxError: Cannot use import statement outside a module at wrapSafe (node:internal/modules/cjs/loader:1024:16) ... ERROR: Something went wrong in @nrwl/run-commands - Command failed: ts-node ../../node_modules/.bin/typeorm migration:generate -n
In my ormConfig.json file, the relevant details are as follows:
{
...
"type": "postgres",
"migrationsTableName": "migration",
"migrations": ["src/migration/*.ts"],
"cli": {
"migrationsDir": "src/migration"
},
"ssl": false
}
If anyone has insights or solutions regarding this issue, your help would be greatly appreciated! Please :)