[TypeError: WebAssembly.instantiate(): Imports argument must be present and must be an object]

Viewed 1103

I'm trying to import a golang WebAssembly component into NodeJS but keep hitting this problem:

[TypeError: WebAssembly.instantiate(): Imports argument must be present and must be an object]

I think the problem is that I need to find a way to include the wasm_exec.js since it works in the Chrome.

Here's what I have tested:

const fs = require('fs');
const buf = fs.readFileSync('./test.wasm');

async function asyncCall() {

    try {
        //listing messages in users mailbox 
          const lib = await WebAssembly.instantiate(new Uint8Array(buf)).then(res => res.instance.exports);

        } catch (err) {
          console.log(err)
        }

    console.log(res);
    // expected output: 'resolved'
  }

  asyncCall();
0 Answers
Related