01. 환경설정 - seongjunhwang/clone_blockchain GitHub Wiki

yarn

  • yarn add global typescript
  • npm install typescript --save-dev

tsconfig.json 생성

  • typescript를 javascript로 어떻게 변환할 건지 정의
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "ES2015",
        "sourceMap": true
    },
    "include": ["index.ts"],
    "exclude": ["node_modules"]
}

compile

  • tsc
  • npx tsc
  • nodejs는 typescript를 이해하지 못하여 javascript로 컴파일하는 과정이 필요

package.json

  • scripts 추가
  "scripts": {
    "start": "node index.js",
    "prestart": "npx tsc"
  }