Skip to content
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

TypeORM connection fails due to SyntaxError #1

Closed
Swiftb0y opened this issue Dec 2, 2019 · 4 comments · Fixed by #3
Closed

TypeORM connection fails due to SyntaxError #1

Swiftb0y opened this issue Dec 2, 2019 · 4 comments · Fixed by #3

Comments

@Swiftb0y
Copy link
Contributor

Swiftb0y commented Dec 2, 2019

Currently, running the code outside of ts-node results in a SyntaxError: Cannot use import statement outside a module because the ormconfig.js is pointing at the src dir when specifying the typeorm entities ("entities": ["src/**/**/**.entity{.ts,.js}"],). This only works from within ts-node. There are two solutions to the problem:

Solution 1

just replace the src with dist. Pro: Simple, minimal change required; Con: requires rebuild when entities are changed.

Solution 2

Convert ormconfig.json to typescript module and construct path conditionally.
detection via TypeStrong/ts-node#846. Pro: more solid approach, doesnt suffer from the Con from solution 1; Con: more complicated, requires bleeding edge version of ts-node, ts-node specific solution.

@pezzetti
Copy link
Owner

pezzetti commented Dec 2, 2019

Hi @Swiftb0y thanks for contributing.
I could use some help to fix this issue.
Could you submit a pull request?

Thanks in advance

@Swiftb0y
Copy link
Contributor Author

Swiftb0y commented Dec 2, 2019

Of course. What Solution do you prefer?

@pezzetti
Copy link
Owner

pezzetti commented Dec 2, 2019

I believe that Solution 2 would be nice. What do you think?

@Swiftb0y
Copy link
Contributor Author

Swiftb0y commented Dec 2, 2019

I need to look into the details a bit more but I think it's possible without too much hassle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants