node로 .ts 파일 실행시키기
node로 .ts 파일을 실행시키면 “syntaxerror: unexpected identifier” 가 발생하였다.
babel-node도 설치해보고 tsconfig도 수정해봤지만 소용x
ts 파일을 node로 실행하려면 ts-node 모듈을 설치해야 한다.
ts-node는 메모리 상에서 티입스크립트를 transpile 하여 바로 실행할 수 있게 해준다.
1
npm install -D ts-node
그리고 package.json에서 스크립트로 등록해주면 ts-node를 바로 사용할 수 있다.
1
2
3
"scripts": {
"start": "ts-node src/index.ts",
}
This post is licensed under CC BY 4.0 by the author.