typeorm: TypeORM does not work with Typscript and NestJS
Issue description
Can’t generate migrations
Expected Behavior
I expect migration:generate to create a migration file.
Actual Behavior
I run this command:
pnpm run typeorm migration:generate -- ./src/migrations/ -d ./src/books.datasource.ts
Which is adapted from the documentation of how to get the typorm CLI to run in Typescript environments: https://typeorm.io/using-cli#if-entities-files-are-in-typescript.
That seems to run:
> typeorm-ts-node-commonjs "migration:generate" "--" "./src/migrations/" "-d" "./src/books.datasource.ts"
And then comes back with:
Not enough non-option arguments: got 0, need at least 1
ELIFECYCLE Command failed with exit code 1.
Steps to reproduce
See above for the exact commands
My Environment
| Dependency | Version |
|---|---|
| Operating System | macOS |
| Node.js version | 18.17.1 |
| Typescript version | 4.9.5 |
| TypeORM version | 0.3.17 |
Additional Context
No response
Relevant Database Driver(s)
- aurora-mysql
- aurora-postgres
- better-sqlite3
- cockroachdb
- cordova
- expo
- mongodb
- mysql
- nativescript
- oracle
- postgres
- react-native
- sap
- spanner
- sqlite
- sqlite-abstract
- sqljs
- sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, but I don’t know how to start. I would need guidance.
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Comments: 15
TypeORM definitely works with Typescript and NestJs, I am currently using it for my project and have used it with previous projects.
You haven’t provided your typeorm datasource so it’s hard to even begin helping you debug your DataSourceOptions.
Here is an example of my data-source.ts file in db/
Here is an example of my migration scripts in package.json
Here is an example of how I use them:
npm run build:migrationsnpm run migration:generate -- db/migrations/<name of migration>