npx tsc --init
{ "compilerOptions": { "module": "CommonJS", // other options... } }
Or for ES modules:
{ "compilerOptions": { "module": "ESNext", "moduleResolution": "node", // other options... } }
For ES modules projects, verify your package.json has "type": "module" added
Try running with the specific module flag
npx ts-node --esm src/index.ts
Or for CommonJS:
npx ts-node --commonjs src/index.ts
Another approach would be to use ts-node-esm explicitly:
npx ts-node-esm src/index.ts