1
我試圖在node.js中運行webassembly模塊,並且得到Wasm decoding failedResult
。我認爲我的問題是將節點Buffer
轉換爲ArrayBuffer
。這裏是我的應用代碼:當我使用emcc hello_world.c -s WASM=1 -o hello.html
我可以加載的模塊,並在瀏覽器中運行它編譯hello world到wasm並在節點中運行
(relevant details)
Wasm decoding failedResult = expected version 0c 00 00 00, found 01 00 00 00 @+4
:
fs.readFileAsync(WASM_PATH)
.then(buf => buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength))
.then(arrayBuffer => Wasm.instantiateModule(arrayBuffer))
.then(results => console.log(results.instance))
.catch(err => console.error(err));
我得到這個錯誤。所以,我很確定這是我的一個問題,或者可能是一些兼容性問題。提前致謝。