Commit 1
chore: init project with TypeScript and tsconfigCommands
mkdir backend && cd backend
npm init -y
npm install --save-dev typescript @types/node
npx tsc --init
mkdir srcUpdate tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"esModuleInterop": true,
"strict": true
}
}Create .gitignore
node_modules
distCommit 2
chore: add ts-node-dev for developmentCommands
npm install --save-dev ts-node-devUpdate 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 devExpected output:
TypeScript is working