VSCode의 터미널에서
1) 디렉토리 생성
2) 생성한 디렉토리에서 npm init --y 입력 ( package.json 파일 생성 )
3) npm i -D typescript ts-node 입력
4) npm i -D @types/node 입력
5) npm i 입력
6) tsc --init ( tsconfig.json 파일 생성 )
7) tsconfig.json 파일 설정
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es5",
"moduleResolution": "node",
"outDir": "dist",
"baseUrl": ".",
"sourceMap": true,
"downlevelIteration": true,
"noImplicitAny": true,
"paths": {"*": ["node_modules/*"]}
},
"include": ["src/**/*"]
}
8) 생성한 디렉토리에서 index.ts 파일 생성
console.log("hi"); 입력 후 저장
9) package.json 파일 설정
{
"name": "생성한 디렉토리 이름",
"version": "1.0.0",
"description": "",
"main": "생성한 디렉토리 이름/index.ts ( 생성한 디렉토리 이름 앞에 /를 붙이지 않는다 )",
"dependencies": {
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
},
"devDependencies": {},
"scripts": {
"dev" : "ts-node src",
"build" : "tsc && node dist"
},
"keywords": [],
"author": "",
"license": "ISC"
}
9) npm run dev 입력
10) hi 확인
11) npm run build 입력
12) tsconfig.json 파일 설정의 "outDir": "dist" 이 부분으로 인하여
dist 디렉토리가 생성되며 index.js 파일과 index.map.js 파일이 생성되며
hi를 확인 할수 있다.
'개발이야기 > TypeScript' 카테고리의 다른 글
타입스크립트 개발환경 만들기(타입스크립트 컴파일러 설치 및 실행) (0) | 2020.07.21 |
---|---|
타입스크립트 개발환경 만들기(nodejs + 크롬 설치) (0) | 2020.07.21 |
타입스크립트 개발환경 만들기(VSCode 설치) (0) | 2020.07.21 |
타입스크립트 개발환경 만들기(scoop 설치) (0) | 2020.07.21 |