New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add typeorm CLI variations that include ts-node
#8776
Conversation
Add `typeorm-ts-node-commonjs` and `typeorm-ts-node-esm` CLI commands. This removes the need to manually write `node --require ts-node/register ./node_modules/typeorm/cli.js` or `node --loader ts-node/esm ./node_modules/typeorm/cli.js` in order to use TypeORM CLI without transpiling the code in advance.
thank you!!! |
@giladgd I just spotted this change released in 0.3.2 and see that the documentation has been updated as well. I currently use the following for my typeorm CLI script: "typeorm": "node -r ts-node/register --preserve-symlinks ./node_modules/typeorm/cli.js", Note it includes Do you know how I could get this flag passed to node under your new |
@cduff You could change your script to this: "typeorm": "NODE_OPTIONS=\"--preserve-symlinks\" typeorm-ts-node-commonjs" If you want it to also work well on Windows, do this instead:
"typeorm": "cross-env NODE_OPTIONS=\"--preserve-symlinks\" typeorm-ts-node-commonjs" |
if windows requires something specific, it's better to document it since there are many windows users out there. |
@pleerock |
Thanks @giladgd I got it working using |
Hi, I've installed version 0.3.4 and followed the doc adding Any ideas what I'm doing wrong? |
@lfaires Your command is wrong, you should use |
@giladgd thanks a lot!! |
Description of change
Add
typeorm-ts-node-commonjs
andtypeorm-ts-node-esm
CLI commands.This removes the need to manually write
node --require ts-node/register ./node_modules/typeorm/cli.js
ornode --loader ts-node/esm ./node_modules/typeorm/cli.js
in order to use TypeORM CLI without transpiling the code in advance.This is more useful now than before since the new CLI in version 0.3 requires you to specify a file path instead of just a file name, so being able to
cd
to a folder and then run a simple and intuitive command is now more important.Previous usage of the CLI in version 0.3:
cd src/db/migrations node --loader ts-node/esm ../../../node_modules/typeorm/cli.js migration:generate -d ../data-source.ts --pretty SomeMigrationName
New possible usage of the CLI:
cd src/db/migrations npx typeorm-ts-node-esm migration:generate -d ../data-source.ts --pretty SomeMigrationName
Pull-Request Checklist
master
branchnpm run format
to apply prettier formattingnpm run test
passes with this changeFixes #0000