remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.13k stars 1.72k forks source link

Nodemon TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" #2155

Closed i-Lucas closed 6 months ago

i-Lucas commented 6 months ago

Hello. I noticed that this problem happens when I am using a node version higher than 18.17.0 LTS

The error occurs when executing the command 'nodemon filename.ts'

Nodemon TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"

System: Ubuntu 22.04.3 LTS. nodemon: ^3.0.2 docker: no

When changing the system node version to v18.17.0, the nodemon executes the .ts file normally.

remy commented 6 months ago

And if you repeat this test without nodemon and use node (or TS or what have you) directly, what do you see? (If it repeats - you'll need to include information to replicate)

Salamante commented 6 months ago

This issue is related with ts-node. Take a look at this thread; https://github.com/TypeStrong/ts-node/issues/2094

I fixed it by running like below; nodemon --exec node --loader ts-node/esm .filename.ts

node version: 20.10.0

remy commented 6 months ago

@Salamante is this worth adding to the FAQ or is this a bug in ts-node?

Salamante commented 6 months ago

@remy I think It's safe to say this is a bug in ts-node.