Error: tsgo: command not found — setting up the TypeScript 7 native preview compiler
TypeScript 7's Go-native compiler ships as a separate package (`@typescript/native-preview`) with its own `tsgo` binary, distinct from the classic `tsc` command that `typescript` provides — installing `typescript` alone doesn't give you `tsgo`. Install the native-preview package explicitly and invoke `tsgo` (or its npx form) instead of expecting `tsc` to switch automatically.
What causes this error
The Go-based rewrite of the TypeScript compiler was distributed during its beta/RC phase as a separate package, @typescript/native-preview, which provides its own tsgo binary — it does not replace the classic tsc command from the main typescript package. Expecting `tsgo` to be available just because `typescript` is installed is the source of this error.
The Fix
# Install the native-preview package explicitly
npm install -D @typescript/native-preview
# Run it via npx (or add it as a script)
npx tsgo --project tsconfig.json
# package.json
"scripts": {
"typecheck:fast": "tsgo --noEmit"
}Editor/language-service support (in VS Code, for example) for the native preview is also a separate extension/setting from the default TypeScript language service — check your editor's TypeScript version selector rather than assuming an update to `typescript` alone switches it over.
Common causes / variations
- Only installing `typescript` and expecting `tsgo` to come along with it
- A CI pipeline referencing `tsgo` before the native-preview package was added to `devDependencies`
- Editor extensions still pointed at the classic language service instead of the native preview's
Related errors
See also: target=es5 no longer supported, TypeScript 6.0 strict by default.
Comments
Loading comments...