DEV Community

Cover image for How to run TypeScript natively in Node.js with TSX

How to run TypeScript natively in Node.js with TSX

Lucas Santos on November 28, 2023

Who hasn't wondered how runtimes like Deno can run TypeScript natively? When will it come to Node? When will we be able to run native TypeScript an...
Collapse
 
moinulmoin profile image
Moinul Moin

for Node.js v20.6.0 and above, we can use this,

node --env-file=.env --import=tsx --watch ./src/index.ts

Collapse
 
adkrix profile image
Andrei Zagoruiko (adkrix)

And can I import custom tsconfig.json like .env?

Collapse
 
amnbhr profile image
Amin Bahari

yes, "--loader" is deprecated on node 20.6.0