package.json 파일 생성 등의 프로젝트 생성
npm init -y
개발에 필요한 패키지 설치
npm i -D typescript tsx nodemon @types/node
tsconfig.json 파일 생성을 위해 다음 명령 수행
npx tsc --init
tsconfig.json에 다음 내용으로 대체
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"rootDir": "./src",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
},
"include": ["src"],
}
dist와 src 폴더를 생성하고 src에 index.ts 파일 생성
packagejson에 다음 내용 추가
{
...
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon",
"build": "tsc",
"start": "node dist/index.js"
},
...
}
nodemon.json 파일 추가 후 다음 내용 입력
{
"watch": ["src"],
"ext": "ts,json",
"exec": "npx tsx ./src/index.ts"
}
개발 시작
npm run dev
index.ts에 다음 코드를 입력하면 터미널에 그 결과가 바로 반영됨







