# Run WebAssembly in NodeRED (Wasmer)

**URL:** <https://discourse.nodered.org/t/run-webassembly-in-nodered-wasmer/80986>\
**Category:** Share Your Nodes\
**Created:** [2 September 2023 18:15 UTC](https://discourse.nodered.org/t/run-webassembly-in-nodered-wasmer/80986 "2023-09-02T18:15:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackcarey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jackcarey/32/61101_2.png) [@jackcarey](https://discourse.nodered.org/u/jackcarey)\
**Post date:** [2 September 2023 18:15 UTC](https://discourse.nodered.org/t/run-webassembly-in-nodered-wasmer/80986/1 "2023-09-02T18:15:21Z")

</div>

Hello, I have started integrating [wasmer-js](https://github.com/wasmerio/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

- [node-red-wasmer - NPM](https://flows.nodered.org/node/@jackcarey/node-red-wasmer)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 September 2023 19:45 UTC](https://discourse.nodered.org/t/run-webassembly-in-nodered-wasmer/80986/2 "2023-09-04T19:45:56Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 September 2023 20:06 UTC](https://discourse.nodered.org/t/run-webassembly-in-nodered-wasmer/80986/3 "2023-09-04T20:06:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jackcarey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jackcarey/32/61101_2.png) [@jackcarey](https://discourse.nodered.org/u/jackcarey)\
**Post date:** [4 September 2023 21:36 UTC](https://discourse.nodered.org/t/run-webassembly-in-nodered-wasmer/80986/4 "2023-09-04T21:36:27Z")

</div>

> 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](https://wasmerio.github.io/wasmer-js/) in a low-code fashion. Right now, I have run the [testing spec](https://github.com/wasmerio/wasmer-js/tree/main/tests) 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](https://www.npmjs.com/package/wasi-js) (which still targets [WASI](https://wasi.dev/), the same as Wasmer), and [emscripten](https://emscripten.org/) (which has it's own non-standard system bindings) could make good candidates for new WebAssembly nodes. That'd help support _any_ `.wasm` file.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 September 2023 22:23 UTC](https://discourse.nodered.org/t/run-webassembly-in-nodered-wasmer/80986/5 "2023-09-04T22:23:39Z")

</div>

Ok thanks for the clarification! Please keep us updated.
