Node "WebAssembly.compile ... module compile failed" in CI
Node failed to compile a WebAssembly module. The .wasm bytes were corrupted, not bundled correctly, or used a Wasm feature the runtime does not support.
What this error means
A tool backed by Wasm (an esbuild-wasm variant, a parser, a crypto lib) fails with "WebAssembly.compile(): ... module compile failed". It works locally where the asset is intact.
CompileError: WebAssembly.compile(): expected magic word 00 61 73 6d,
found 3c 21 44 4f @+0
at async compileWasm (node:internal/...)Common causes
The .wasm asset was not bundled as binary
A bundler treated the .wasm file as text/JS or did not emit it, so the bytes are wrong (often an HTML 404 page captured instead).
Truncated or feature-incompatible module
A partial download, or a module compiled with Wasm features the Node version lacks, fails the compile.
How to fix it
Bundle .wasm as a binary asset
Configure the bundler to emit .wasm as a file/binary loader so the bytes reach the output intact.
esbuild.build({
loader: { '.wasm': 'file' },
// ensure the emitted .wasm path matches the runtime fetch
});Use a Node version that supports the features
Upgrade Node so the Wasm feature set (SIMD, threads) the module needs is available, and verify the asset is not truncated.
- Confirm the magic bytes start with 00 61 73 6d, not an HTML page.
- Pin a Node version supporting the required Wasm features.
- Re-fetch the asset to rule out truncation.
How to prevent it
- Emit .wasm with a binary/file loader, never as text.
- Verify the asset path resolves (no 404 captured as the module).
- Use a Node version that supports the Wasm features in use.