From ef5444a2b373d0b75afbc276a6380b0cb72ed49e Mon Sep 17 00:00:00 2001 From: sangwook Date: Wed, 14 Jan 2026 23:38:05 +0900 Subject: [PATCH 1/2] lib: fix TypeScript support check in jitless mode WebAssembly is disabled when Node.js is run with --jitless. The internal TypeScript stripper relies on WebAssembly, and previously failed obscurely with a ReferenceError in this mode. This commit adds an explicit check for WebAssembly support when loading the TypeScript parser. If WebAssembly is unavailable, it now throws a descriptive ERR_WEBASSEMBLY_NOT_SUPPORTED error. Fixes: https://github.com/nodejs/node/issues/61353 --- doc/api/errors.md | 8 ++++++++ lib/internal/errors.js | 3 +++ lib/internal/util.js | 4 ++++ test/es-module/test-typescript.mjs | 11 +++++++++++ 4 files changed, 26 insertions(+) diff --git a/doc/api/errors.md b/doc/api/errors.md index a63fb28ab8933d..c059fac476e503 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -3350,6 +3350,14 @@ The WASI instance has already started. The WASI instance has not been started. + + +### `ERR_WEBASSEMBLY_NOT_SUPPORTED` + +A feature requiring WebAssembly was used, but WebAssembly is not supported or +has been disabled in the current environment (for example, when running with +`--jitless`). The error message specifies which feature requires WebAssembly. + ### `ERR_WEBASSEMBLY_RESPONSE` diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 5fa4437b09e556..7c4728627731fe 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1905,6 +1905,9 @@ E('ERR_VM_MODULE_NOT_MODULE', 'Provided module is not an instance of Module', Error); E('ERR_VM_MODULE_STATUS', 'Module status %s', Error); E('ERR_WASI_ALREADY_STARTED', 'WASI instance has already started', Error); +E('ERR_WEBASSEMBLY_NOT_SUPPORTED', + 'WebAssembly is not supported in this environment, but is required for %s', + Error); E('ERR_WEBASSEMBLY_RESPONSE', 'WebAssembly response %s', TypeError); E('ERR_WORKER_INIT_FAILED', 'Worker initialization failure: %s', Error); E('ERR_WORKER_INVALID_EXEC_ARGV', (errors, msg = 'invalid execArgv flags') => diff --git a/lib/internal/util.js b/lib/internal/util.js index 9739422d08284a..28bb83e558c426 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -46,6 +46,7 @@ const { SymbolPrototypeGetDescription, SymbolReplace, SymbolSplit, + globalThis, } = primordials; const { @@ -53,6 +54,7 @@ const { ERR_NO_CRYPTO, ERR_NO_TYPESCRIPT, ERR_UNKNOWN_SIGNAL, + ERR_WEBASSEMBLY_NOT_SUPPORTED, }, isErrorStackTraceLimitWritable, overrideStackTrace, @@ -244,6 +246,8 @@ function assertCrypto() { function assertTypeScript() { if (noTypeScript) throw new ERR_NO_TYPESCRIPT(); + if (globalThis.WebAssembly === undefined) + throw new ERR_WEBASSEMBLY_NOT_SUPPORTED('TypeScript'); } /** diff --git a/test/es-module/test-typescript.mjs b/test/es-module/test-typescript.mjs index df25f60defd35b..2e98bc3f289d1e 100644 --- a/test/es-module/test-typescript.mjs +++ b/test/es-module/test-typescript.mjs @@ -342,3 +342,14 @@ test('check transform types warning', async () => { assert.match(result.stdout, /Hello, TypeScript!/); assert.strictEqual(result.code, 0); }); + +test('expect error when executing a TypeScript file with --jitless', async () => { + const result = await spawnPromisified(process.execPath, [ + '--jitless', + fixtures.path('typescript/ts/test-typescript.ts'), + ]); + + assert.match(result.stderr, /ERR_WEBASSEMBLY_NOT_SUPPORTED/); + assert.match(result.stderr, /WebAssembly is not supported in this environment, but is required for TypeScript/); + assert.strictEqual(result.code, 1); +}); From f689364dd97bf0b47f7b39cf35d4857ed03152a1 Mon Sep 17 00:00:00 2001 From: sangwook <73056306+Han5991@users.noreply.github.com> Date: Thu, 15 Jan 2026 18:59:49 +0900 Subject: [PATCH 2/2] doc: refine WebAssembly error documentation Co-authored-by: Marco Ippolito --- doc/api/errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index c059fac476e503..b55f659c39ed94 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -3356,7 +3356,7 @@ The WASI instance has not been started. A feature requiring WebAssembly was used, but WebAssembly is not supported or has been disabled in the current environment (for example, when running with -`--jitless`). The error message specifies which feature requires WebAssembly. +`--jitless`).