npm i -g typescript // 현재 컴퓨터에 설치
npm i typescript // 로컬로 설치(현재 폴더에 설치)
npm init -y
npm i -D express ts-node nodemon @types/node @types/express
express : node.js의 프레임워크ts-node : Typescript를 실행 시키는 라이브러리. 컴파일하지 않고 바로 실행 시킴nodemon : 파일을 수정할 때마다 자동으로 재실행시켜줌@types/express : TypeScript 프로젝트에서 Express의 타입을 가진 라이브러리@types/node : TypeScript 프로젝트에서 Node의 타입을 가진 라이브러리TypeScript로 짜여진 코드를 JavaScript로 컴파일하는 옵션을 설정하는 파일
npx tsc --init
{
"compilerOptions": {
"target": "es6",
"module": "commonjs", //어떤 모듈 방식으로 컴파일할지 설정
"outDir": "./dist", //컴파일 후 js 파일들이 생성되는 곳
"rootDir": "./src", //루트 폴더
"strict": true, //strict 옵션 활성화
"moduleResolution": "node", //모듈 해석 방법 설정: 'node' (Node.js)
"esModuleInterop": true
}
}
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node dist/index.js",
"build": "tsc -p .",
"dev": "nodemon --watch \"src/**/*.ts\" --exec \"ts-node\" src/index.ts"
},
.gitignore 자동생성 사이트
https://www.toptal.com/developers/gitignore