mkdir express-ts-app cd express-ts-app npm init -y
npm install express npm install -D typescript tsx @types/express @types/node
npx tsc --init
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": "./src",
"outDir": "./dist",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"types": ["node"],
"sourceMap": true
},
"include": ["src"]
}
{
...,
"type": "module",
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"start": "node dist/index.js"
},
...,
}
express-ts-app/
├─ src/
│ ├─ index.ts
│ ├─ routes/
│ │ └─ hello.ts
├─ package.json
├─ tsconfig.json
npm run dev
npx create-next-app@latest