Run WebAssembly in NodeRED (Wasmer)

Hello, I have started integrating wasmer-js into a node so that WebAssembly modules can be run by providing a URL and a few other details. The motivation behind this is to easily allow custom functionality to be written in languages other than JavaScript, such as Python, C++, Rust, or Go. I have implemented the basics of the Wasmer API, however the node currently doesn't handle linking between WebAssembly modules and external functions. While this isn't so much of an issue in NodeRED, because outputs can be passed in messages, I am planning to include it in the future.

If you end up trying this out then please do leave feedback here! Thanks

Hi @jackcarey,

Seems like an interesting node. Thanks for sharing this with our community!!

BTW I tried to install it, but I failed to do that:

59 verbose node v16.20.0
60 verbose npm  v8.19.4
61 error code EBADENGINE
62 error engine Unsupported engine
63 error engine Not compatible with your version of node/npm: @jackcarey/node-red-wasmer@0.0.5
64 error notsup Not compatible with your version of node/npm: @jackcarey/node-red-wasmer@0.0.5
64 error notsup Required: {"node":">=18.0.0"}
64 error notsup Actual:   {"npm":"8.19.4","node":"v16.20.0"}
55 verbose stack Error: Unsupported engine
55 verbose stack     at checkEngine (/usr/lib/node_modules/npm/node_modules/npm-install-checks/lib/index.js:14:25)
55 verbose stack     at Arborist.[checkEngineAndPlatform] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:228:11)
55 verbose stack     at Arborist.buildIdealTree (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:214:42)
55 verbose stack     at async Promise.all (index 1)
55 verbose stack     at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:154:5)
55 verbose stack     at async Install.exec (/usr/lib/node_modules/npm/lib/commands/install.js:145:5)
55 verbose stack     at async module.exports (/usr/lib/node_modules/npm/lib/cli.js:78:5)
56 verbose pkgid @jackcarey/node-red-wasmer@0.0.5
57 verbose cwd /home/pi/.node-red
58 verbose Linux 6.1.21-v8+
59 verbose node v16.20.0
60 verbose npm  v8.19.4
61 error code EBADENGINE
62 error engine Unsupported engine
63 error engine Not compatible with your version of node/npm: @jackcarey/node-red-wasmer@0.0.5

So at least NodeJs version 18 is required for this node. Although I assume this will become the standard in the near future, it might be useful to mention this shortly on the readme page.

Bart

1 Like

I can confirm that it works when I upgrade NodeJs to 18.x

Does this mean you can run any WebAssembly file with this node, or did I understood this not correctly?

Does this mean you can run any WebAssembly file with this node, or did I understood this not correctly?

I cannot guarantee every .wasm. file will work, as WebAssembly standards are still maturing and changing. However, in time, my aim is to mirror the Wasmer API in a low-code fashion. Right now, I have run the testing spec against everything but test.wasm, which currently fails.

Should there be a need, and if I have time to investigate, alternatives APIs like wasi-js (which still targets WASI, the same as Wasmer), and emscripten (which has it's own non-standard system bindings) could make good candidates for new WebAssembly nodes. That'd help support any .wasm file.

Ok thanks for the clarification! Please keep us updated.