6

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: module to package.json
  • change module: commonjs to ES2022 in tsconfig.json
  • change the command ts-node into node --loader ts-node/esm

now all things are working perfectly, but it seems that tsconfig-paths doesn't work in esm.

minimal reproductions:

in both projects:

  • run npm run build to test compiling with typescript with esm
  • run npm start to test ts-node
  • run npm start:paths to test ts-node with tsconfig-paths
Sh eldeeb
  • 1,589
  • 3
  • 18
  • 41
  • The Node.js runtime analog of TypeScript's [path mapping](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) is [subpath imports](https://nodejs.org/api/packages.html#subpath-imports). – jsejcksn Jan 17 '22 at 13:10

0 Answers0