DEV Community

Cover image for How to set up TypeScript with Node.js and Express (2023)

How to set up TypeScript with Node.js and Express (2023)

Sukanta Das on July 04, 2023

In this article, we’ll cover a Best way to set up TypeScript in an Express app, understanding the basic constraints that come with it. Table of co...
Collapse
 
codefromrvk profile image
codefromrvk • Edited

instead of nodemon in package.json it should have been ts-node-dev

Collapse
 
cristain profile image
Sukanta Das

yes this work can be done by ts-node-dev also

Collapse
 
tabrownies profile image
Timothy Brown

nodemon can run typescript files if you have the dependency ts-node installed.

Collapse
 
brngranado profile image
Bryan Granado

If is'nt work for you try this

"scripts": {
"build": "npx tsc",
"start": "node dist/index.js",
"dev": "ts-node-dev --respawn --transpile-only app.ts"
},

Collapse
 
insanityaery profile image
insanityAery

"dev": " ts-node-dev --respawn --transpile-only src/server.ts"

Collapse
 
ajl profile image
Muhammed Ajmal

everything will be fine..but even after running the server i can't find the dist folder

Collapse
 
cristain profile image
Sukanta Das

To see dist folder

npm run build
Enter fullscreen mode Exit fullscreen mode

after running this you will see dist folder

Collapse
 
__a81012f597 profile image
Игорь Мешалкин

This is a great guide! Simple and useful. Thank you very much.

Collapse
 
cristain profile image
Sukanta Das

Thank you for your kind words! We're glad you found the guide helpful.

Collapse
 
levialkalidamat profile image
Levi alkali damat

work well for me. thanks

Collapse
 
devtalha profile image
talha

Not working showing success message of server is runnig. But when i try to request something request pn pedning...

Collapse
 
cristain profile image
Sukanta Das

I think there is some mistake on your side
please recheck the code and try to set it up using the steps mentioned.

Collapse
 
dev_carnage profile image
dev carnage

Everything is working. But in cases where I am not using typescript type properly, it's not giving any error while running server, any suggestions what I can use here?