jorgebodega / typeorm-seeding

🌱 A delightful way to seed test data into your database.
https://www.npmjs.com/package/@jorgebodega/typeorm-seeding
MIT License
75 stars 11 forks source link

Error: Cannot find module './typeorm-seeding' #317

Open angelxmoreno opened 10 months ago

angelxmoreno commented 10 months ago

running

yarn ts-node typeorm-seeding -d src/data-source.ts src/seeders/**/*.ts

Throws the error:

yarn run v1.22.19
warning package.json: No license field
$ /Users/user/project/typeorm-seeding-example/node_modules/.bin/ts-node typeorm-seeding -d src/data-source.ts src/seeders/CreateUsers.ts
node:internal/modules/cjs/loader:1080
throw err;
^

Error: Cannot find module './typeorm-seeding'
Require stack:
- /Users/user/project/typeorm-seeding-example/imaginaryUncacheableRequireResolveScript
  at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
  at Function.resolve (node:internal/modules/cjs/helpers:125:19)
  at requireResolveNonCached (/Users/user/project/typeorm-seeding-example/node_modules/ts-node/dist/bin.js:549:16)
  at getProjectSearchDir (/Users/user/project/typeorm-seeding-example/node_modules/ts-node/dist/bin.js:519:40)
  at phase3 (/Users/user/project/typeorm-seeding-example/node_modules/ts-node/dist/bin.js:267:27)
  at bootstrap (/Users/user/project/typeorm-seeding-example/node_modules/ts-node/dist/bin.js:47:30)
  at main (/Users/user/project/typeorm-seeding-example/node_modules/ts-node/dist/bin.js:33:12)
  at Object.<anonymous> (/Users/user/project/typeorm-seeding-example/node_modules/ts-node/dist/bin.js:579:5)
  at Module._compile (node:internal/modules/cjs/loader:1256:14)
  at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
  '/Users/user/project/typeorm-seeding-example/imaginaryUncacheableRequireResolveScript'
  ]
}

Node.js v18.18.2
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I took a look at typeorm-seeding-example and noticed that

ts-node ./node_modules/@jorgebodega/typeorm-seeding/dist/cli.js seed -d src/data-source.ts src/seeders/**/*.ts

does work. however, I am in a monorepo and strongly prefer not relying on the node_modules path.

What am I doing wrong?