https://github.com/somnathkar000/basic-ts-setup
This repository demonstrates a minimal setup for running TypeScript files seamlessly using nodemon and ts-node. The configuration allows automatic compilation and execution of TypeScript files whenever changes are detected.
https://github.com/somnathkar000/basic-ts-setup
basic-setup nodejs nodemon ts-node
Last synced: about 1 year ago
JSON representation
This repository demonstrates a minimal setup for running TypeScript files seamlessly using nodemon and ts-node. The configuration allows automatic compilation and execution of TypeScript files whenever changes are detected.
- Host: GitHub
- URL: https://github.com/somnathkar000/basic-ts-setup
- Owner: SomnathKar000
- Created: 2025-02-01T17:12:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-01T18:20:02.000Z (about 1 year ago)
- Last Synced: 2025-02-01T18:26:24.417Z (about 1 year ago)
- Topics: basic-setup, nodejs, nodemon, ts-node
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic-TS-Setup π
A minimal TypeScript setup using **nodemon** and **ts-node** for seamless development.
## Features
- π **Live reloading** with `nodemon`
- π **No manual compilation** using `ts-node`
- π Watches `.ts` files inside the `src/` directory
## Installation & Usage
### 1οΈβ£ Install dependencies
```sh
npm install
2οΈβ£ Start development mode
npm run dev
3οΈβ£ Project Structure
π explore-ts
β£ π src
β β π index.ts # Entry point
β£ π package.json
β£ π nodemon.json
β π README.md
Configuration
package.json
{
"name": "explore-ts",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "nodemon"
},
"devDependencies": {
"nodemon": "^3.1.9",
"ts-node": "^10.9.2"
}
}
nodemon.json
{
"watch": ["src"],
"ext": "ts",
"exec": "ts-node ./src/index.ts"
}
```
In the nodemon.json file, these fields are configuring how Nodemon watches and restarts your TypeScript application. Hereβs what each field means:
1. watch: [βsrcβ]
- This tells Nodemon to watch the "src" directory for any changes.
- If any file inside "src" changes, Nodemon will restart the application.
2. "ext": "ts,js"
- Specifies the file extensions that Nodemon should watch.
- In this case, it only watches .ts (TypeScript) files.
- If you also wanted to watch JavaScript files, you could use:
```sh
"ext": "ts,js"
```
3. exec: βts-node ./src/index.tsβ
- This is the command Nodemon executes when restarting.
- It runs ts-node ./src/index.ts, which compiles and runs the TypeScript file index.ts using ts-node.
How It Works
- If any .ts file in src/ changes, Nodemon automatically restarts ts-node ./src/index.ts.
Notes
- Ensure you have Node.js installed.
- The entry file should be src/index.ts.
- Modify nodemon.json to watch additional files if needed.