0% found this document useful (0 votes)
9 views3 pages

Run Node - Js TS App

Uploaded by

Ola Badawy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Run Node - Js TS App

Uploaded by

Ola Badawy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Page 1 of 3

Table of Contents
1. Install [Link] and TypeScript
2. Initialize Your Project
3. Install Dependencies
4. Configure TypeScript
5. Create Your App
6. Running Your App
Option 1: Run with ts-node (for development)

Option 2: Compile and Run (for production)

7. Automate with [Link] Scripts

how to run nodejs and typescript app?

To run a [Link] and TypeScript application, follow these steps:


1. Install [Link] and TypeScript
Ensure you have [Link] installed. You can check by running:
sh

node -v
npm -v

If not installed, download from [Link].

Then, install TypeScript globally:


Page 2 of 3
sh

npm install -g typescript

2. Initialize Your Project


Run the following command to create a [Link] file:

sh

npm init -y

3. Install Dependencies
Install TypeScript and ts-node (for running TypeScript files directly):

sh

npm install typescript ts-node @types/node --save-dev

4. Configure TypeScript
Generate a [Link] file:

sh

tsc --init

Modify [Link] as needed. A basic configuration:

json

{
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src",
"strict": true
}
}

5. Create Your App


Create a src/[Link] file and add:

typescript

[Link]("Hello, TypeScript with [Link]!");


6. Running Your App
Page 3 of 3

Option 1: Run with ts-node (for development)


sh

npx ts-node src/[Link]

Option 2: Compile and Run (for production)


Compile TypeScript:

sh

npx tsc

Run the compiled JavaScript:

sh

node dist/[Link]

7. Automate with [Link] Scripts


Modify [Link] to add scripts:

json

"scripts": {
"dev": "ts-node src/[Link]",
"build": "tsc",
"start": "node dist/[Link]"
}

Now you can run:

sh

npm run dev # Development mode


npm run build # Compile TypeScript
npm start # Run compiled JavaScript

Let me know if you need further clarification! 🚀

You might also like