VSCode

How to Run TypeScript in VSCode: Quick Guide

How to Run TypeScript in VSCode: Quick Guide

VSCode doesn’t compile TypeScript. You get an editor, an integrated terminal and a debugger, and that’s where its job ends. So the real decision is what turns your .ts file into something that runs. You can build with tsc and execute the JavaScript with node, or skip the build and hand the .ts file to tsx or to Node.js itself.

The second option is a lot less fiddly than it used to be. Node.js now executes erasable TypeScript natively. Type stripping has been on by default since v22.18.0 and v23.6.0, and stable since v24.12.0 and v25.2.0 (Node.js documentation, 2026).

Nothing checks your types on that route, though. You still want a separate tsc --noEmit run to catch type errors. And enums fail at launch, because they need actual JavaScript generated for them.

How do you run TypeScript in VSCode?

YouTube player

Nothing runs a .ts file as written. A compiler (or a runtime that strips out the types) turns it into JavaScript first, and Node.js executes that.

The editor ships with TypeScript language support. It doesn’t ship with tsc, the compiler, according to the VS Code documentation. You install that part yourself.

Your options are tsc plus node, Node.js type stripping, tsx, or the Code Runner extension (which quietly needs ts-node installed before it does anything useful).

MethodCommandType checks while runningBest for
tsc plus nodetsc, then node dist/file.jsYes, tsc reports errors during the buildCode that ships
Node.js type strippingnode file.tsNoSmall scripts on a recent Node.js
tsxnpx tsx file.tsNoEnums, decorators, tsconfig paths
Code RunnerCtrl+Alt+NDepends on the ts-node setupOne-off files in the editor

If type errors should block the run, go with tsc plus node. Running Node.js 22.18 or later (or 23.6 or later on the 23 line) with nothing but erasable syntax in the file? Then just run it with node directly.

Enums, decorators or tsconfig paths push you toward tsx.

My own default is tsc for anything that ships and tsx for throwaway scripts. I rarely think past that.

Whichever route you take, Node.js ends up running JavaScript, so you can run that output like any other JavaScript file in VSCode.

What to install before running TypeScript in VSCode

YouTube player

You need Node.js, the TypeScript package, and VSCode. That covers every method in this article. If you want to skip the compile step, pick a Node.js version that runs erasable TypeScript without any flags, which means v22.18.0 or later on the 22 line, or v23.6.0 onward (Node.js documentation).

See what’s already on the machine before installing anything:

node -v
npm -v
tsc --version

If the terminal panel is hidden, open the integrated terminal in VSCode with Ctrl+` and run them there. The compiler comes from npm, installed either globally or per project.

Worth knowing: since July 8, 2026, the typescript package on npm installs TypeScript 7.0, the Go-native compiler. A fresh install of either kind gets you 7.x. The commands and the tsc name haven’t changed.

Global install

Run npm install -g typescript once and tsc works in every folder on the machine. The VS Code docs confirm the install with tsc –version.

The problem shows up later. Your global tsc can drift from the version a teammate or a CI job uses, and then you’re chasing errors that only happen on one machine.

Local install per project

For anything you commit, I’d go local every time. Run npm install --save-dev typescript, then call the compiler with npx tsc.

The version gets recorded in package.json, so everyone on the project compiles with the same release. VS Code’s documentation also recommends the local install as the way to avoid interactions with other TypeScript projects on the machine.

There’s one thing that trips people up here. The editor’s IntelliSense runs on its own built-in TypeScript version, which has nothing to do with the compiler you just installed. Use the command “TypeScript: Select TypeScript Version” to switch the editor over to the workspace copy. If you’re on TypeScript 7.0, Microsoft’s release announcement points VS Code users to the TypeScript Native Preview extension, and once it’s installed it becomes the editor’s default language service.

Compiling and running a TypeScript file with tsc and Node.js

This is the slowest route to set up and the one I trust most.

  1. Create hello.ts in a new folder with const name: string = "VSCode"; console.log("Hello, " + name);
  2. Run tsc --init in the integrated terminal. It creates a tsconfig.json file (DigitalOcean tutorial).
  3. Open tsconfig.json and set "outDir": "dist" so compiled files stay out of the source folder.
  4. Run tsc with no file names. Without input files, tsc looks for tsconfig.json in the current folder and builds the project it describes. (The VS Code tutorial’s build task does the same thing explicitly with tsc -p ..)
  5. Run node dist/hello.js. The VS Code tutorial runs its own compiled file the same way, with node helloworld.js.

Which tsconfig.json options decide the output

TypeScript 6.0 shipped on March 23, 2026 and reset several defaults. TypeScript 7.0, released on July 8, 2026, kept them. So if you copy a config out of an older tutorial, don’t expect it to behave the way the tutorial says.

  • target sets the ECMAScript version of the emitted code. It now defaults to the newest stable version, currently es2025. Target es5 was deprecated in 6.0 and is an error in 7.0.
  • module controls the output module format, and the default is esnext.
  • outDir is the folder for compiled files.
  • rootDir defaults to the folder that holds tsconfig.json. A file in src/ lands in dist/src/ unless you set rootDir to src, which catches almost everyone once.
  • strict has been true by default since 6.0.
  • sourceMap writes .js.map files. Breakpoints in .ts files need them.

The types default changed too. It’s now an empty array, so TypeScript no longer loads every package under node_modules/@types.

In practice, code that touches Node.js globals such as process needs @types/node installed and "types": ["node"] in tsconfig.json. Otherwise you get a wall of “cannot find name” errors that look scarier than they are.

Where the VS Code tutorial and the current compiler disagree

The tutorial’s sample config, as retrieved in November 2026, sets target ES5, module CommonJS and outDir out. TypeScript 6.0 deprecated es5 and made ES2015 the lowest target, according to the Microsoft TypeScript team, and TypeScript 7.0 removed es5 outright. That sample now fails with the current compiler.

The Node.js documentation does its own thing. Its sample tsconfig uses “module”: “nodenext”. When the sources conflict, trust the compiler’s release notes over a tutorial snippet, and take only the outDir idea from the older sample.

Why tsc hello.ts skips tsconfig.json

Passing a file name to tsc ignores the config file. That’s always been true, but TypeScript 6.0 started telling you about it: error TS5112 appears when a tsconfig exists but file names are passed on the command line, and --ignoreConfig suppresses it. TypeScript 7.0 keeps the rule. File paths on the command line are refused in a folder with a tsconfig.json unless you pass --ignoreConfig.

Running TypeScript without a compile step

Node.js type stripping, tsx, and ts-node (the one Code Runner calls) all skip the build. The first two trade away type checking at run time for speed. ts-node is different and does type-check by default, unless you turn on transpileOnly.

Node.js type stripping

Node.js replaces TypeScript syntax with whitespace and performs no type checking, according to its documentation. A nice side effect is that line numbers in stack traces stay correct without source maps.

The feature arrived in stages across Node.js releases:

  • v22.6.0 added type stripping behind the –experimental-strip-types flag
  • v23.6.0 and v22.18.0 turned it on by default
  • v24.3.0 and v22.18.0 removed the experimental warning
  • v24.12.0 and v25.2.0 marked it stable

On v22.18.0 or later, or v23.6.0 or later, node hello.ts just works. Older versions need the –experimental-strip-types flag.

Where it falls over is syntax that needs code generation. Type stripping alone can’t handle enums, parameter properties, namespaces with runtime code or import aliases, and it raises ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX for them. Decorators fail with a parser error. .tsx files aren’t supported at all.

Imports are pickier too. You need the real extension (./file.ts) and the type keyword on type-only imports. The loader ignores tsconfig.json, so paths aliases don’t resolve.

Type errors never show up at run time. Run npx tsc –noEmit separately for that.

tsx and ts-node

Between the two, tsx is easier. Install it with npm install –save-dev tsx, then run npx tsx your-file.ts, or node –import=tsx your-file.ts if you prefer that form.

It behaves like a near drop-in replacement for node, and it handles CommonJS, ESM and tsconfig.json paths (tsx documentation). Under the hood it transforms code through esbuild, which doesn’t type-check. Pair it with tsc --noEmit.

ts-node runs the actual TypeScript compiler, so it’s slower than tsx’s esbuild transform. The tsx site also says ts-node is complicated to use and lacks ESM support. That’s one vendor talking about a competitor, so take it with some salt.

The bigger issue is that ts-node depends on the compiler’s JavaScript API, and TypeScript 7.0 ships without one. On ts-node’s issue tracker, users report it crashing since 7.0 arrived and fixing it by pinning TypeScript to 6.0.3. If you’re keeping ts-node, pin TypeScript 6 in that project. Microsoft’s compatibility package, npm install -D typescript@npm:@typescript/typescript6, installs it.

Code Runner extension

Press Ctrl+Alt+N to run the current file with Code Runner. Output goes to the Output Window by default. Set code-runner.runInTerminal to true if you’d rather see it in the integrated terminal (I would).

The extension’s default executor for TypeScript is ts-node, and its README says you need ts-node installed to run TypeScript. Since ts-node breaks with TypeScript 7.0, that default inherits the same TypeScript 6 pin. You can get around it with the code-runner.executorMap setting, which maps a language to the command that runs it. Point the typescript entry at another runner such as tsx and the problem goes away.

Code Runner is fine for single files. For real project work, the integrated terminal gives you full control over flags and working folders.

Automating the build with a tasks.json build task

Choose Terminal, then Configure Default Build Task, and pick tsc: build or tsc: watch. VSCode writes a tasks.json file. From then on, Ctrl+Shift+B (Cmd+Shift+B on macOS) runs the task without a picker.

Open the generated file and you’ll find tsc: build, which runs the compiler once, or tsc: watch, which regenerates the .js file on every save. The line "isDefault": true in the build group is what skips the picker. $tsc is the problem matcher that reads compiler output.

The file doesn’t define a new task. It annotates the built-in tsc task with “type”: “typescript” and “tsconfig”: “tsconfig.json”, so the build reads the same config as tsc in the terminal.

Errors appear inline in the editor and in the Problems panel, and Ctrl+Shift+M opens the list. Watch tasks use the $tsc-watch matcher instead.

I keep tsc: watch running while I write and do a tsc: build before a commit.

On the tsx or Node.js type stripping routes, you can ignore all of this. Nothing compiles there, so there’s no build task to run.

How to debug TypeScript in VSCode with breakpoints

When you debug, the debugger is running the compiled JavaScript and mapping each line back to your .ts file through source maps. Generate them by compiling with the –sourcemap option or by setting sourceMap to true in tsconfig.json, per the VS Code documentation.

The runtime is still Node.js, so the habits from debugging JavaScript carry over: breakpoints, the call stack and variable inspection all work the same way.

Create the launch.json file

Open the Run and Debug view with Ctrl+Shift+D and select the “create a launch.json file” link. VSCode writes the file to the .vscode folder using defaults it detects from the project.

The VS Code documentation’s sample Node.js configuration uses these attributes:

  • "type": "node" and "request": "launch" start a new Node.js process
  • "program" is the .ts entry file, such as ${workspaceFolder}/hello.ts
  • "preLaunchTask" points at the tsc build task ("tsc: build - tsconfig.json" in the sample), so the output gets rebuilt before every session. If your generated file doesn’t have this line, add it.
  • "outFiles" tells the debugger where the generated JavaScript lives

The compiled files from the earlier steps sit in dist, not next to the source. When generated JavaScript isn’t next to its source, outFiles needs glob patterns, for example ${workspaceFolder}/dist/**/*.js.

Press F5 to start the session.

When breakpoints do not bind

Gray, hollow breakpoints usually mean one of a few things. sourceMap might be false, or the .js.map files predate your last tsconfig.json edit. outFiles could be pointing at the wrong folder.

Or the .ts file changed after the last compile and no preLaunchTask reruns tsc. That last one gets me more than I’d like to admit.

The VS Code debugging page, as retrieved in November 2026, covers only the compile-first route. It doesn’t describe debugging through tsx or Node.js type stripping, so treat any launch.json recipe for those runners as unverified until a breakpoint actually binds in your own project.

Common errors when running TypeScript in VSCode

Most broken setups hit one of the errors below. The two Windows-and-PATH ones account for a surprising share of them.

ErrorLikely causeFix
tsc is not recognizedNo global install, or the npm global folder is missing from PATHUse npx tsc, or add the folder from npm config get prefix to PATH
PowerShell refuses to run tscRestricted execution policySet RemoteSigned for the current user
ERR_UNSUPPORTED_TYPESCRIPT_SYNTAXEnum or runtime namespace under type strippingRewrite the syntax or run through tsx
ERR_UNKNOWN_FILE_EXTENSION for .tsts-node meets “type”: “module”Add –esm, drop “type”: “module”, or switch to tsx
Editor errors differ from tscEditor uses its built-in TypeScriptPoint it at the workspace install

PowerShell refuses to run tsc

Microsoft Learn lists Restricted as the effective policy for Windows clients when no scope sets one. Restricted permits individual commands but won’t run scripts, and the global tsc is a script.

The fix is Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. Microsoft warns that this kind of command can succeed without changing the effective policy, so run Get-ExecutionPolicy -List afterwards and check which scope wins.

ES module errors with ts-node

According to the ts-node docs, you set “type”: “module” in package.json, set module to ESNext, ES2015 or ES2020 in tsconfig.json, and pass –esm. The Node.js docs, meanwhile, use nodenext for module in their sample tsconfig for running TypeScript.

So the two disagree. And ts-node’s own advice comes with a caveat attached. Its page calls Node’s ESM loader hooks experimental and doesn’t recommend its ESM support for production, describing CommonJS as simpler and more widely supported.

On a new project, honestly, skip the fight and use tsx. Even more so now that ts-node also needs TypeScript pinned to 6.

Node.js refuses enums

Node.js added the –experimental-transform-types flag in v22.7.0 for syntax like enums and namespaces. The Node.js documentation lists the flag as removed in v26.0.0, so don’t build a workflow around it.

Replace the enum with a const object plus a union type, or run the file through tsx.

Editor and terminal report different type errors

This happens when the editor falls back to its built-in version and checks against a different compiler than tsc. Setting js/ts.tsdk.path to a workspace install points both at the same one. With TypeScript 7.0 in the workspace, install the TypeScript Native Preview extension so the editor runs the same major version as tsc.

You can open settings.json in VSCode and add the entry there. That way the choice travels with the project instead of depending on a command you have to remember each session.

FAQ About Running TypeScript in VSCode

Can VSCode run TypeScript for a browser project?

Not directly. Browsers execute only JavaScript, so tsc or a bundler has to compile the code first.

For debugging, the Run and Debug view lets you create a launch.json file with the Web App (Edge) or Web App (Chrome) template. With source maps enabled, breakpoints stay on the .ts source.

How do I try a TypeScript beta or nightly build in VSCode?

Install the JavaScript and TypeScript Nightly extension to get the newest language features in the editor. The compiler is a separate install, so pull a pre-release tag through npm as well, such as npm install -D typescript@next for nightlies. For TypeScript 7 nightlies, Microsoft has been publishing builds under @typescript/native-preview, and its editor counterpart is the TypeScript Native Preview extension.

Do Deno and Bun run TypeScript without any setup?

Yes, once the runtime is installed. Deno runs TypeScript with nothing beyond the Deno CLI, and Bun executes .ts files with no extra configuration.

Neither one stops on type errors by default, though. Deno’s documentation says type errors do not stop your code unless you ask, and Bun does not typecheck at all. tsc is still what catches them.

Which shortcuts and commands differ on Windows, macOS and Linux?

Mostly just the modifier key. On macOS the build task runs with Cmd+Shift+B and Run and Debug opens with Cmd+Shift+D.

PowerShell’s policy is the one real platform difference. Microsoft documents the default execution policy as Unrestricted on non-Windows computers, so PowerShell on macOS and Linux never hits the blocked-script error.

Which Run Method Should a Real Project Keep?

For a real project, let tsc be the only judge of type errors and pick the runner per job. A compiled build for code that ships, tsx or Node.js type stripping for scripts.

The reason is simple. Node.js type stripping, tsx, Bun and Deno all execute without checking types, so none of the zero-build routes catches a type error by itself.

Install typescript as a devDependency and add a tsc --noEmit script that runs before every commit. Choose the runner after that. The check covers all of them, so the choice matters less than people think.

TypeScript 7.0, the Go-native compiler, became the default typescript release on July 8, 2026, and Microsoft built 6.0 as the bridge to it. If your project upgrades to 7.0, re-test anything that loads the compiler as a library: ts-node, Code Runner’s default executor and the editor’s language service. This position was verified in November 2026.

With the run method settled, a TypeScript cheat sheet covers the syntax worth learning next.

Bogdan Sandu

Stay sharp. Ship better code.

Every week: one curated article, one tool worth knowing, one tip you can use tomorrow. No noise, no padding.