Commit 1
chore: init project with TypeScript and tsconfig
Commands
mkdir backend && cd backend
npm init -y
npm install --save-dev typescript @types/node
npx tsc --init
mkdir src
Update tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"esModuleInterop": true,
"strict": true
}
}
Create .gitignore
node_modules
dist
Commit 2
chore: add ts-node-dev for development
Commands
npm install --save-dev ts-node-dev
Update package.json
:
"scripts": {
"dev": "ts-node-dev --respawn src/index.ts"
}
Verification
Create src/index.ts
:
const message: string = "TypeScript is working";
console.log(message);
Run the development server:
npm run dev
Expected output:
TypeScript is working
Top comments (0)