title: Uncaught (in promise) LinkError: WebAssembly Instantiation: Import #1 module="env" function="__memory_base" error: global import must be a number
body: <p>I am following the Google CodeLab <a href="https://codelabs.developers.google.com/codelabs/web-assembly-intro/index.html#0" rel="nofollow noreferrer">An Introduction to Web Assembly</a> to learn WebAssembly.</p>
  
  <p>When I work on the step of <a href="https://codelabs.developers.google.com/codelabs/web-assembly-intro/index.html#3" rel="nofollow noreferrer">Serve over HTTP</a>, I hit the below error:</p>
  
  <pre><code>Uncaught (in promise) LinkError: WebAssembly Instantiation: Import #1 module="env" function="__memory_base" error: global import must be a number or WebAssembly.Global object
      at createWebAssembly (http://127.0.0.1:8000/:11:57)
      at async init (http://127.0.0.1:8000/:46:18)
  </code></pre>
  
  <p>Here is the JavaScript running on the webpage:</p>
  
  <pre><code>  async function createWebAssembly(path, importObject) {
      const result = await window.fetch(path);
      const bytes = await result.arrayBuffer();
      return WebAssembly.instantiate(bytes, importObject);
    }
  
    const memory = new WebAssembly.Memory({initial: 256, maximum: 256});
    let exports = null;
  
    async function init() {
      const env = {
        'abortStackOverflow': _ =&gt; { throw new Error('overflow'); },
        'table': new WebAssembly.Table({initial: 0, maximum: 0, element: 'anyfunc'}),
        'tableBase': 0,
        'memory': memory,
        'memoryBase': 1024,
        'STACKTOP': 0,
        'STACK_MAX': memory.buffer.byteLength,
      };
      const importObject = {env};
  
      const wasm = await createWebAssembly('output.wasm', importObject);
      exports = wasm.instance.exports;
      console.info('got exports', exports);
      exports._board_init();  // setup lyff board
  
      // TODO: interact with lyff board
    }
    init();
  </code></pre>
  
  <p>The error is from <code>WebAssembly.instantiate(bytes, importObject)</code>; however, I cannot step into that function though. Can someone please let me know what I am missing? Thank you in advance!</p>