typeorm-seeding icon indicating copy to clipboard operation
typeorm-seeding copied to clipboard

Could not load seeders!

Open jagoanmamah opened this issue 1 year ago • 2 comments

Screenshot 2023-12-26 at 07 55 37

Screenshot 2023-12-26 at 07 54 19

jagoanmamah avatar Dec 26 '23 00:12 jagoanmamah

Sorry, I cannot work just with an image without any context.

Please, try to create a reproducible example in a repo, or at least, a decent amount of code.

jorgebodega avatar Dec 26 '23 18:12 jorgebodega

I ran into the same issue, I debugged it: the problem is that the "run" method receives the following array as paths: [ 'seed', './seed/0_clear.ts', './seed/1_create_users.ts', ... ]

@jagoanmamah did you have a seed folder too? Based on the image your case can be a different one.

The root cause is that the seed command is prepended to the paths array (maybe the "commander" package is misused) and if you store the seeds under a folder named "seed" you can see this error message because we try to load the module from that folder.

I figured out two workarounds, both of them are working independently:

  1. Remove the "seed" command when calling the CLI (for me it's something like that: ts-node -r tsconfig-paths/register ./node_modules/@jorgebodega/typeorm-seeding/dist/cli.js -d ./data-source.ts ./seed/*.ts)
  2. Rename the "seed" folder to something else, for example "seeders": (for me it's something like that: ts-node -r tsconfig-paths/register ./node_modules/@jorgebodega/typeorm-seeding/dist/cli.js seed -d ./data-source.ts ./seeders/*.ts)

I don't have time to fix this issue and send a PR but I hope these informations are going to help you!

6uliver avatar Feb 12 '24 21:02 6uliver