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] Root Param should be respected in OrmConfig file #63

Closed
johannesschobel opened this issue May 4, 2020 · 4 comments
Closed

[Bug] Root Param should be respected in OrmConfig file #63

johannesschobel opened this issue May 4, 2020 · 4 comments

Comments

@johannesschobel
Copy link

Dear @hirsch88 ,

today i tried to add your library to my existing project in order to provide respective seeding functionality.

For the context, please note that i use a mono-repository with nrwl/nx. I have a few applications (all stored in apps/ folder of my project root), whereas one is a NestJS API. The latter uses TypeORM with an ormconfig.js file and your library.

However, when i want to run the commands, i have to set the additional --root parameter, because my ormconfig.js file is not stored in the root folder of the mono-repository, but in the specific application folder (e.g., apps/api/src/ormconfig.js).

My apps/api/src/ormconfig.js file looks like this:

module.exports = {
  // ... lots of params to connect to the database
  synchronize: false,
  seeds: ['my/custom/path/to/seeds/*.ts'],
};

However, because i need to call the seeder command with --root param, i expected the seeds parameter to prepend respective root path. For example, the path should be apps/api/src/my/custom/path/to/seeds/*.ts.

Not sure, if i did something wrong, but my seeds were not properly found. If i entered the full path (relative to the root folder of the project itself) it worked out!

All the best

@hirsch88
Copy link
Member

Hi @johannesschobel unfortunately you have to use the --root argument for monorepos. Howerver, if you run the seed command inside of your apps/api folder it should work.

@aledoroshenko
Copy link

And what is the correct way to set root? Having projectName/src/config/typeorm.config.ts I'm trying this: "seed:config": "ts-node ./node_modules/typeorm-seeding/dist/cli.js config --configName typeorm.config.ts --root /src/config", but have an error Error: Cannot find module '/src/config/typeorm.config.ts'.

@SaveYourTime
Copy link

And what is the correct way to set root? Having projectName/src/config/typeorm.config.ts I'm trying this: "seed:config": "ts-node ./node_modules/typeorm-seeding/dist/cli.js config --configName typeorm.config.ts --root /src/config", but have an error Error: Cannot find module '/src/config/typeorm.config.ts'.

Same here!

@trompx
Copy link

trompx commented Jul 8, 2020

Same here, the doc is not in sync with how it works currently.
What worked for me is to specify the whole config path with configName, omitting root completly:
--configName ./src/api/config/ormconfig.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

5 participants