Home · Topic · 14 entries
TypeScript errors when Node runs your .ts files
Node now runs TypeScript files without a build step, which moved a whole class of errors from the compiler to the runtime: extensions Node refuses, syntax that cannot be stripped, and imports that only resolve for the type checker. Every entry below was reproduced on current Node and TypeScript, with the exact versions written at the top of the post.
- No.053
Bun "error: Cannot find module": every cause, tested
Bun prints the same Cannot find module error for six different problems. Each one reproduced on Bun 1.4.2 on Windows and Linux, with the fix that worked.
> error: Cannot find module '@mono/ui' from 'D:\nk-repro\bun-cnf\e-mono\apps\web\index.ts'
FIXED8 min - No.044
SvelteKit 3 migration, tested: what sv migrate misses
sv migrate sveltekit-3 upgraded every package and moved the config correctly, but left three removed options in place, so the first build failed three times in a row. Worse, it rewrote a working {base}/about link into one that 404s, and that passed both the build and svelte-check.
TESTED4 min - No.031
TypeScript 7 migration guide: breaking changes, tested
Every option TypeScript 6.0.3 marked as deprecated was a hard error on 7.0.2, and ignoreDeprecations no longer silences it. Two defaults that arrived in 6.0 (strict on, @types not loaded automatically) also break projects coming straight from 5.9.
TESTED6 min - No.030
Does Next.js, Angular, Vue or NestJS work with TypeScript 7?
Next.js 16.3.6 built and type-checked on plain TypeScript 7.0.2. Angular 22.2, Vue with vue-tsc 3.3 and NestJS 12 all failed, and all three built again on Microsoft's side-by-side setup, with tsc still on 7.0.2. Nuxt, Svelte and Astro still built on 7, but their type-check commands refused it until TypeScript 6 was installed alongside.
TESTED5 min - No.029
Angular compilation initialization failed on TypeScript 7
Angular 22 crashes on TypeScript 7 with reading 'Error', not the usual version warning. What actually failed, and the setup that builds with tsc 7, tested.
> Application bundle generation failed. [0.412 seconds]
FIXED2 min - No.025
Fix: TypeScript enum is not supported in strip-only mode
Node's ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX for enum, parameter properties, namespace, export = and import =. Two ways to run it unchanged, both tested.
> enum Color { Red, Green }
FIXED3 min - No.022
Fix: typescript-eslint does not support TS 7.0 (ESLint on TS 7)
When typescript-eslint will support TypeScript 7, why npm refuses the install, and the setup that keeps TypeScript 7 while ESLint runs normally today.
> npm error code ERESOLVE
FIXED3 min - No.020
Upgrading to TypeScript 7? 9 tools tested (ESLint, Jest, ts-node)
Plain TypeScript 7 broke ts-node, ts-jest, typescript-eslint, TypeDoc and ts-loader, and npm refused to install it at all without a flag. Microsoft's side-by-side setup ran all 9 tools with no errors while tsc stayed on 7.
TESTED6 min - No.016
Fix: Cannot read properties of undefined (reading 'fileExists')
ts-node and webpack's ts-loader crash with this on TypeScript 7, before your code even runs. Which versions do it, why npm didn't warn you, and four ways out.
> C:\project\node_modules\ts-node\dist\configuration.js:91
FIXED3 min - No.015
Fix: This syntax is not allowed when 'erasableSyntaxOnly' is enabled
TS1294: TypeScript rejects your enum, namespace or constructor shorthand. Why new projects turn this on, what each piece becomes, and when to switch it off.
> src/a.ts(1,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
FIXED3 min - No.014
Fix: ERR_MODULE_NOT_FOUND Cannot find module in ES modules
Node can't find a file that is clearly there. What ES modules changed about relative imports, why TypeScript path aliases break at runtime, and what to change.
> node:internal/modules/esm/resolve:275
FIXED2 min - No.013
Fix: Unknown file extension ".ts" (ERR_UNKNOWN_FILE_EXTENSION)
Node refuses to run your TypeScript file. The version where this stops happening, what ts-node has to do with it, and the one-line way to run .ts today.
> node:internal/modules/esm/get_format:189
FIXED3 min - No.012
Bun vs Node.js 24 benchmark: startup, TypeScript and tests
Bun started 1.7× faster, ran a TypeScript file 3× faster and finished the same test suite 5× faster. Node won the tight number-crunching loop. The HTTP test hit a limit of this machine, not of either runtime.
TESTED3 min - No.010
Fix: Vite “Failed to resolve import” for @/ path aliases
Vite can't resolve your @/ imports even though tsconfig looks right. The config that fixes it and the settings that don't. Reproduced on Vite 8.
> [vite] Internal server error: Failed to resolve import "@/utils/hello"
FIXED1 min
Post card · Newsletter
Get the next fix in your inbox.
One short email when a new entry is published. No spam, never shared, and you can leave any time.
— Nilay