2023-11-24
2313
#node#typescript
Aman Mittal
22050
Nov 24, 2023 β‹… 8 min read

How to set up TypeScript with Node.js and Express

Aman Mittal πŸ‘¨β€πŸ’» Developer πŸ‘‰ Node.js, React, React Native | Tech Blogger with 1M+ views on Medium

Recent posts:

Nx Adoption Guide: Overview, Examples, And Alternatives

Nx adoption guide: Overview, examples, and alternatives

Let’s explore Nx features, use cases, alternatives, and more to help you assess whether it’s the right tool for your needs.

Andrew Evans
Mar 28, 2024 β‹… 9 min read
Understanding Security In React Native Applications

Understanding security in React Native applications

Explore the various security threats facing React Native mobile applications and how to mitigate them.

Wisdom Ekpotu
Mar 27, 2024 β‹… 10 min read
Warp Adoption Guide: Overview, Examples, And Alternatives

warp adoption guide: Overview, examples, and alternatives

The warp web framework for Rust offers many enticing features. Let’s see when and why you should consider using warp in your projects.

Ukeje Goodness
Mar 26, 2024 β‹… 8 min read
Integrating Next Js And Signalr For Enhanced Real Time Web App Capabilities

Integrating Next.js and SignalR to build real-time web apps

In this tutorial, you’ll learn how to integrate Next.js and SignalR to build an enhanced real-time web application.

Clara Ekekenta
Mar 25, 2024 β‹… 8 min read
View all posts

37 Replies to "How to set up TypeScript with Node.js and Express"

  1. What’s the best command setup for deploying and running something like this in production? There are now compiled JS files in build/, but other files (e.g., package.json, static HTML, etc.) are all in their original locations. And, we haven’t created a script in package.json to run the built app.

  2. okayy,, then how can i use other plugin to work with my express typescript. am i should install plugin that support in typescript or not ?

  3. Choose any middleware you need, but make sure DefinitelyTyped has the corresponding Typescript @types/* mappings available. Most popular NodeJS middleware packages are supported in the DefinitelyTyped project.

    1. Hey, if you are running localhost, you do not require “https” until you want to intentionally use HTTPS.

    1. In the article above, the “outDir” is referring to the config option. The “./dist” is the value.

      Are you referring to something specific? Can you please point me to that?

    1. The `main` poperty in the `package.json` indicates the entry point and it should point out to Javascript compiled output. So it should be “main”:”dist/index.js” as we are using typescript here, if it was just just Javascript we can just use the index.js.

      1. Thanks. Ok just so everyone is 100% clear. package.json should be changed to:
        “main”: “dist/index.js”,

  4. Excellent tutorial! One minor note is that the protocol should not be `https` since express is not secure by default, e.g, this line should be changed to just `http` — `console.log(`⚑️[server]: Server is running at http://localhost:${port}`)`

  5. had to remove “module”: “commonjs” from tsconfig.js as the error “ReferenceError: exports is not defined in ES module scope”

  6. anyone has a sample github repo for this? please include an example repo so we know where to place the files at. im guessing all the files should be in an dist folder?

Leave a Reply