I have a typescript project that uses commonjs modules, I use ts-node to run it, and tsconfig-paths to resolve tsconfig.compilerOptions.paths at runtime.
now I want my project to migrate to use es modules, so I made some changes:
- add
type: moduleto package.json - change
module: commonjstoES2022in tsconfig.json - change the command
ts-nodeintonode --loader ts-node/esm
now all things are working perfectly, but it seems that tsconfig-paths doesn't work in esm.
minimal reproductions:
es module project that is forked from the commonjs one, but modified to use es modules
in both projects:
- run
npm run buildto test compiling with typescript with esm - run
npm startto testts-node - run
npm start:pathsto testts-nodewithtsconfig-paths