typeormts-nodeyarn-v2

Using TypeORM CLI with Yarn Berry and TS Path Aliases


How can you pass the tsconfig-paths/register module to ts-node when using typeorm-ts-node-commonjs?

Most examples show an interface like: ts-node -r tsconfig-paths/register ./node_modules/typeorm.cli.js

The docs vaguely say "If you want to load more modules like module-alias you can add more --require my-module-supporting-register" but do not provide a usage example in conjunction with using the prebuilt type orm command typeorm-ts-node-commonjs.

I have tried something like yarn typeorm-ts-node-commonjs -r tsconfig-paths/register but that doesn't work as "-r" is not a arg of typeorm-ts-node-commonjs. I have also tried something like ts-node -r tsconfig-paths/register typeorm-ts-node-commonjs but then typeorm-ts-node-commonjs is not found.


Solution

  • I think I have this solved by doing the following:

    NODE_OPTIONS='-r ./.pnp.cjs -r tsconfig-paths/register' typeorm-ts-node-commonjs