LoginSignup
15
7

More than 3 years have passed since last update.

tscコマンドを使わずに.tsファイルを実行する

Posted at

結論

これまでtscコマンドでコンパイルしてから実行していた

$ tsc
$ node ./dist/example.js

以下のように、1回のコマンドで実行出来る

$ npx ts-node ./src/example.ts

必要な準備

前提

npm5.2.0以上が必要

$ npm --version
5.6.0

ts-nodeをインストール

$ npm install typescript
$ npm install ts-node

1コマンドで実行出来るようになる

$ npx ts-node ./src/example.ts

参考記事

https://qiita.com/tonkotsuboy_com/items/8227f5993769c3df533d
https://employment.en-japan.com/engineerhub/entry/2019/04/16/103000

15
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
7