ReferenceError: WebAssembly is not defined

Viewed 6886

I'm using ttest nodejs module in application. Due to updates to it I tried to use updated version ttest@2.0.0. When module start compute data the error appears:

ReferenceError: WebAssembly is not defined

The NodeJS version - 6.9.1.

Error appears in next place:

class CephesWrapper {
  constructor(sync) {
    // Initialize the runtime's memory
    this._wasmMemory = new WebAssembly.Memory({
      'initial': TOTAL_MEMORY / WASM_PAGE_SIZE,
      'maximum': TOTAL_MEMORY / WASM_PAGE_SIZE
    });
.....
  }
}

Is there any advices about solving this issue? Is it possible to define WebAssembly?

3 Answers

The WebAssembly support is added in NodeJs 8.0.0. Update your NodeJS to make it work.

In my case, the problem was that I was running my browser in safe mode (Mozilla Firefox). Simply shutdown your browser completely and restart. This will quit safe mode (If stuck in safe mode, see here)

For reference, I had found this solution here : https://github.com/mozilla-iot/gateway/issues/2047

Even my node version was 12, and npm version was 6. I was getting the reference error for webassembly.

So I updated the node with latest version(16), it changed the npm version also. Now the reference issue is fixed.

D:\ReactJS\react_demo>node -v

v16.14.0

D:\ReactJS\react_demo>npm -v

8.3.1

Related