Defaulting to `ts-node` is confusing when using ESM loaders
See original GitHub issue- Versions: node@v16.15.1, darwin@21.6.0
nodemon -v: 2.0.20- Operating system/terminal environment (powershell, gitshell, etc): macOS, Terminal.app, zsh
- Using Docker? What image: no
- Command you ran:
NODE_OPTIONS='--loader @esbuild-kit/esm-loader' nodemon src/server.ts
Expected behaviour
I was expecting @esbuild-kit/esm-loader being used to load my TypeScript files, as that is the case when I run NODE_OPTIONS='--loader @esbuild-kit/esm-loader' node src/server.ts (same command but with node instead of nodemon).
Actual behaviour
It uses ts-node in order to transpile the TypeScript files.
I only noticed this because source maps wasn’t working properly, and upon investigating that I realised that nodemon had actually used ts-node to transpile the typescript files.
Steps to reproduce
- Create the following
package.jsonfile{ "type": "module", "dependencies": { "@esbuild-kit/esm-loader": "^2.5.0", "nodemon": "^2.0.20" } } - Run
npm install - Create the following
index.tsfile:const test = (foo: string) => { throw new Error(foo) } test('foo') - Run
NODE_OPTIONS='--loader @esbuild-kit/esm-loader' node index.ts - Observe nice stack trace
- Run
NODE_OPTIONS='--loader @esbuild-kit/esm-loader' nodemon index.ts -
failed to start process, “ts-node” exec not found
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
running node with loader ts-node/esm.js requires imports to ...
I solved it with these experimental features on Node v14.15.0 . node --loader ts-node/esm --experimental-specifier-resolution=node ...
Read more >API - ESBuild
To join a set of files together with esbuild, import them all into a single entry point file and bundle just that one...
Read more >Debug Node.js Apps using Visual Studio Code
Setting up a project for Node.js debugging is straightforward with VS Code providing appropriate launch configuration defaults and snippets. There are a few ......
Read more >tsup
bundle typescript library with ease. ... By default tsup bundles all import -ed modules but dependencies and ... Read more about esm support...
Read more >is ts-node es modules by default? : r/typescript - Reddit
You must also ensure node is passed --loader. The ts-node CLI will do this automatically with our esm option. Note: --esm must spawn...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I genuinely don’t care about TS support, but it’s been in nodemon for too long that removing it would probably break expectations.
I think checking the
--loaderis the best (soft) approach that could solve this issue.friendly ping @remy