Node Express typescript Setup
This project is a basic Node.js Express server using TypeScript. It includes Nodemon for development and TSX for faster TypeScript execution without needing a build step while developing.
Folder setup
mkdir server && cd servernpm init -ymkdir server && cd servernpm init -y
Install Dependencies
npm install expressnpm install express
Dev Dependencies
npm i -D typescript @types/node @types/express nodemon tsxnpm i -D typescript @types/node @types/express nodemon tsx
Initialize TypeScript Create typeconfig.json file
npx tsc --initnpx tsc --init
nodemon.json
{"watch": ["src"],"ignore": ["src/**/*/.spec.ts"],"ext": "ts,json","exec": "tsx --env-file=.env src/server.ts"}{"watch": ["src"],"ignore": ["src/**/*/.spec.ts"],"ext": "ts,json","exec": "tsx --env-file=.env src/server.ts"}
Note: tsx lets you run TS directly without compiling during development.
Scripts (package.json)
script : {"dev": "nodemon","start": "node ./dist/src/server.js","build": "tsc"}script : {"dev": "nodemon","start": "node ./dist/src/server.js","build": "tsc"}
| Feature | Tool | | ----------------- | ------------------------- | | Web Framework | Express | | Language | TypeScript | | Live Dev Reload | Nodemon | | Fast TS Execution | TSX | | Compile to JS | TypeScript Compiler (tsc) |