[TypeScript] Run a TypeScript file with ts-node

Created on November 30, 2026

Install ts-node and TypeScript with npm, then pass the file you want to run to ts-node.

npm install -g typescript ts-node
console.log("Hello");

Save the example as hello.ts. This command sets the module format explicitly so it also works in a directory with no TypeScript configuration.

ts-node --compiler-options '{"module":"CommonJS"}' hello.ts
Hello
TypeScript