How to fix ERR_UNKNOWN_FILE_EXTENSION in #TypeScript

preview_player
Показать описание
In this TypeScript tutorial, we will explore different TypeScript loaders, including ts-node, tsx, and tsimp. We will also discuss the differences between loading CommonJS modules and ECMAScript modules in Node v18 and Node v20.

*My FREE programming apps:*

*My FREE TypeScript Course:*

Timeline:
00:00 Introduction
01:36 Syntax Error: Unexpected token
02:44 Select TypeScript Version
04:10 Using ts-node
05:01 Showing node require
05:50 ERR_UNKNOWN_FILE_EXTENSION and ts-node-esm
07:16 ERR_UNKNOWN_FILE_EXTENSION with Node v20
08:20 Showing node loader
08:55 Deactivating experimental warnings
10:00 Missing stack traces in Node v20 with ts-node
12:20 Showing TypeScript Execute (tsx)
13:30 Type checking with tsx
14:58 TypeScript Import Loader (tsimp)
17:00 Compilation Diagnostics
19:10 Showing cross-env
19:50 Note on development dependencies
Рекомендации по теме
Комментарии
Автор

Thank you Benny! Amazing video, not only sharing the solution but explaining why it's the best solution available at the moment! Tks a lot

humaitrix
Автор

This is easily the most underrated TS channel on YouTube. Thank you for your videos Benny.

krnel_errr
Автор

😮 Mouth fell open watching this. There's no way that today's copy/paste developers are going to create quality software with scenarios like this.
I've been doing this for decades, have been following advice for all of these various tools, to solve these problems, and had no clue about the details that you provided here. OMG - Thank you!
I need to change my approach to this tooling ... maybe go back to BASIC. 😂

tonyg_nerd
Автор

Great video. That was the last thing I couldn't figure out in my ts node setup

MonsterSmart
Автор

Excellent videos .. one of the best videos in TS

HemantKumar-ykjk
Автор

Thanks for your comprehensive video! I was struggling with those errors for 5 hours before finding a solution. I tried tsx and noticed that while it’s fast, it lacks type checking. Finally, I ended up using the command:



nodemon --exec node --loader ts-node/esm src/index.ts

This setup does perform type checking. For example, if you write let x: string = 20, nodemon crashes the app with an error. However, I noticed that, like node with ts-node/esm, it doesn’t provide a stack trace for errors. Do you have any suggestion?

mahdiahmadi
Автор

Thank you so much for your explanation, it helped me a lot

leonardogonzalezrodriguez
Автор

can we run this main.ts directly in the aws lambda or do we need to convert to js ?? i am not sure how can we use this for aws lambda ??

HemantKumar-ykjk
Автор

haha, i work with separated workspace and this save me hahaha

rama
Автор

Its so stupid that ts-node --esm is not working with node v20+

evlbon
Автор

Thanks but what if i have to use nodemon

seeyou
Автор

now: "tsc --noEmit && tsx src/main.ts"

Михаил-цфщ
Автор

how to do it with nodemon "node --loader ts-node/esm && nodemon ./index.ts"

sayandedotcom