When will Node.js' Webassembly API be synchronized with the browser?
now node.js have error ,when run wasm file.
Error: Wasm.instantiateModule(): Wasm decoding failedResult = expected magic word 00 61 73 6d, found 28 6d 6f 64 @+0
Node doesn't provide that API. It's entirely dependent upon the version of V8.
@mscdex thanks
hope use new version v8 ^-^
Note that the module you are trying to load may not be encoded properly, as wasm modules should start with the magic word 0x6d736100 and a version number (that is also what the error message is complaining about). See the WASM encoding spec. Does the module work in browsers?
Also I have tried to run WASM with the master build (which includes V8 5.8.283.38 ) before and it actually works properly. The current stable Node.js release (7.9.0) ships V8 5.5.372.43, which is much older than the one in master and released before WASM specification 1.0.
I noticed the OP is using Wasm.instantiateModule(), which is the old (non-standard?) interface. The new one is WebAssembly.instantiate() and is exposed by default in this newer version of V8. You can try out the nightly builds to load a properly built WASM module.
yes, node.js 8.x+ support.
I think this has been answered, so I'm going to close. Feel free to ask more questions.
FWIW, the bytes 28 6d 6f 64 are (mod in ASCII - if you see that error, it means you're wrongly loading a text-format (.wast) WebAssembly file instead of a binary one.