Node.js support

Many existing JavaScript apps simply use Node.js built-in APIs. In order to support and reuse these JavaScript apps, we are in the process of implementing many Node.JS APIs for WasmEdge QuickJS. The goal is to have unmodified Node.js programs running in WasmEdge QuickJS.

In order to use Node.js APIs in WasmEdge, you must make the modules directory from wasmedge-quickjs accessible to the WasmEdge Runtime. The simplest approach is to clone the wasmedge-quickjs repo, and run the Node.js app from the repo's top directory.

git clone
cd wasmedge-quickjs
curl -OL
cp -r /path/to/my_node_app .
wasmedge --dir .:. wasmedge_quickjs.wasm my_node_app/index.js

If you want to run wasmedge from a directory outside of the repo, you will need to tell it where to find the modules directory using the --dir option. A typical command will look like this: wasmedge --dir .:. --dir ./modules:/path/to/modules wasmedge_quickjs.wasm app.js

The progress of Node.js support in WasmEdge QuickJS is tracked in this issue. There are two approaches for supporting Node.js APIs in WasmEdge QuickJS.

The JavaScript modules

Some Node.js functions can be implemented in pure JavaScript using the modules approach. For example,

The Rust internal modules

Other Node.js functions must be implemented in Rust using the internal_module approach. There are two reasons for that. First, some Node.js API functions are CPU intensive (e.g., encoding) and is most efficiently implemented in Rust. Second, some Node.js API functions require access to the underlying system (e.g., networking and file system) through native host functions.

Node.js compatibility support in WasmEdge QuickJS is a work in progress. It is a great way for new developers to get familiar with WasmEdge QuickJS. Join us!