Node 22.22 runs TypeScript. Ubuntu's Node 22.22 doesn't.
Four test files in my site's repo import TypeScript directly. faq.test.mjs pulls in src/lib/faq.ts , and three others do the same with their own modules. There is no build step and no loader in between: the script is node --test "test/*.test.mjs" , and type stripping has been on by default since Node 22.18.0, so Node strips the types and runs what's left. In CI those tests pass. The workflow asks…
Node 22.22, when using TypeScript, fails to run tests due to the absence of TypeScript support in the Node binary provided by the Ubuntu package. The feature is enabled by default in Node 22.18.0 and later. However, Ubuntu's Node 22.22.1 does not support the --experimental-strip-types flag, as indicated by the output of process.features.typescript which returns false.
This issue is resolved by using the official Node 22.22.1 build from nodejs.org, which correctly identifies the feature as enabled. The Debian changelog explains that this change was made due to the use of swc, which requires the amaro package and disables the ability to execute TypeScript files using the --experimental-strip-types flag.
The fix involves extracting the official Node binary and placing it in a location that takes precedence over the Ubuntu package in the PATH. Running the test files with the official Node binary results in all tests passing, confirming that the issue was with the Ubuntu-provided Node binary.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.