I also get this issue when I run the same example code. I have emcc v1.38.12
I was able to look at the required imports of the wasm module to see what was missing:
const wasmModule = new WebAssembly.Module(bytecode);
console.log("imports", WebAssembly.Module.imports(wasmModule));
This output:
imports [ { module: 'env', name: 'table', kind: 'table' },
{ module: 'env', name: 'memoryBase', kind: 'global' },
{ module: 'env', name: 'tableBase', kind: 'global' },
{ module: 'env', name: 'abort', kind: 'function' } ]
So perhaps it needs an abort function to be defined.
I added a new member to imports.env:
abort: _ => { throw new Error('abort');},
I think that needed to be done, but it wasn't the problem, it turns out that WebAssemblyTable needs to have initial set to 2 instead of 0.
table: new WebAssembly.Table({ initial: 2, element: 'anyfunc' })