To run a script written in TypeScript from the terminal, outside of the browser, we cannot use the regular Node.js binary.
We need to install the ts-node command as below:
$ npm install -g ts-node
If TypeScript itself is not installed, install it with:
$ npm install -g typescript
Then, we can run the TypeScript file using:
$ ts-node file.ts