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

Bug: OptionsError: The database options could not be located/loaded. #888

Open
timurkhakhalev opened this issue Feb 12, 2024 · 5 comments
Open

Comments

@timurkhakhalev
Copy link

timurkhakhalev commented Feb 12, 2024

Versions

  • Node: 20
  • OS: Ubuntu 20

Reproduction

Can't load data-source when in tsconfig.json there are other options than "outDir": "dist", "rootDir": "./src",

or when there are no dist folder in project

I have dive into your source code and noticed that in the path variable here

there are :

[
  '/home/timur/dev/project',
  '/home/timur/dev/project/dist/database/type-orm'
]

I expect there /home/timur/dev/project/src/database/type-orm or at least /home/timur/dev/project/my-outDir-name/database/type-orm

Steps to reproduce

  1. Change "outDir" to "bin" / remove current "dist" folder / specify "rootDir" to "."
  2. tsx --env-file=.env ./node_modules/typeorm-extension/bin/cli.mjs seed:run -d src/database/type-orm/index.ts --preserveFilePaths
  3. OptionsError: The database options could not be located/loaded.

What is Expected?

What is actually happening?

@tada5hi
Copy link
Owner

tada5hi commented Apr 9, 2024

tsx is not supported yet.
Please try passing --preserveFilePaths as additional cli option.

@tada5hi
Copy link
Owner

tada5hi commented Apr 9, 2024

at the moment typeorm-extension assumes that you execute the cli on build files.

export function detectCodeTransformation() : `${CodeTransformation}` {

Maybe you can create a pr on how to detect tsx environment ☺️ ✌️

@coler-j
Copy link

coler-j commented May 24, 2024

I am also getting this error and --preserveFilePaths unfortunately did not resolve.

@tada5hi
Copy link
Owner

tada5hi commented Jul 10, 2024

can you provide a reproduction repo ?

@setaman
Copy link

setaman commented Oct 9, 2024

at the moment typeorm-extension assumes that you execute the cli on build files.

Hitting the same error in a NestJs project after switching to SWC, but that comment pointed me in the right direction. Adjusting the data source path pointing to /dist directory did the job in my case:

npx ts-node node_modules/typeorm-extension/bin/cli.cjs seed:run -d dist/seed/config/typeorm.seed.config.js

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

No branches or pull requests

4 participants