-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Cannot use mikro-orm-cli in TypeScript with ESM and NodeNext module resolution #3485
Comments
You can see working ESM project here: https://stackblitz.com/edit/mikro-orm-esm-repro The trick to make the CLI work is the edit: huh the repro did not have the script for CLI, so here it is:
Add this to your NPM scripts are use that instead of npx/yarn run the the CLI. |
I'm sure that
It doesn't have @mikro-orm/cli. To make my esm project work is easy, I did it before, but I still can't use the cli. |
The reason for NPM script is to have the loader registered. I see you even found out the trick with loaders yourself. Next time I would appreciate you put such information into the issue description. IMHO this is a wontfix, you already do the right thing to solve it. Just wrap it into NPM script. |
Just to shed a bit more light into this - AFAIK the I will be definitely experimenting with this more, especially because the new getting started guide I am working on is ESM and also talks about this problem - and I would very much like to not mention it at all and have things working out of box... But I dont think they can at this point. |
FYI open a GH discussion to verify we can't do better: |
I think we could do one thing - we could expose |
… loader Using this command will allow dynamic importing of TS files from a CLI context. This is an alternative to using `NODE_OPTIONS='--loader ts-node/esm --no-warnings'` explicitly. Closes #3485
I am trying ESM, but when I use
When I use a package.json script:
All work as expected:
|
Well, that sounds like |
After see the CLI code and how you register the mikro-orm/packages/cli/src/esm.ts Line 1 in 307d3a1
I have changed in my
by this (see the
And all work as expected:
|
Interesting, PR welcome 👍 |
Describe the bug
With these configuration,
mikro-orm
command will not work as expected.For reprodution, error stack and more details, see https://github.com/lixiang810/mikro-orm-repro
The text was updated successfully, but these errors were encountered: