Single executable applications and native addons
Packaging a Node app as one executable with the SEA feature, how native addons work through Node-API and node-gyp, and running WebAssembly from Node instead.
ES modules in Node and interoppackage.json fields and exportsDeploying Node applications
Single executable applications and native addons
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A single executable application (SEA) injects your bundled script into a copy of the `node` binary, so the result runs on a machine with no Node installed. It is the way to ship a CLI or desktop helper as one file.
- SEA is still marked stability 1.1, active development, in the Node 26 docs. In Node 25.5 and later the build is `node --build-sea sea-config.json`, where the config names `main`, `output` and optional `assets`. Older guides use `--experimental-sea-config` plus a separate injection tool.
- SEA embeds one script, so bundle your app and its dependencies first, with a tool like esbuild. Native addons and dynamic `require` of files on disk need extra care.
- Your executable is as large as the Node binary, tens of megabytes, and you must build per platform and architecture, and sign it where the OS requires.
- Not every Node binary supports SEA. The Homebrew build on my machine answered `Single executable application is disabled`, so check that the Node you build with is built with SEA support, for example an official release binary.
- A native addon is compiled C or C++ loaded with `require('./addon.node')`. Write it against Node-API (N-API), which has a stable ABI across Node versions, instead of V8 directly, and build it with `node-gyp` or a prebuilt binary.
- WebAssembly runs in Node with no compiler toolchain. For portable fast compute, such as a codec or a parser, it is often a simpler alternative to a native addon.
Shipping Node without Node
Deploying a service, as in the previous lesson, controls the machine it runs on. Distributing a tool to other people does not. A CLI that requires “install Node 24, then run npm install -g” loses users at step one. You want one file that just runs.
A single executable application, SEA, is Node’s own answer. Node takes a copy of the node binary and injects a prepared blob that contains your script. When the resulting executable starts, it checks for the blob. If it finds one, it runs that script. If not, it behaves like regular node. The runtime and your code ship as one file, and the user installs nothing.
This is the last lesson in the roadmap, and it is also where the boundaries of Node’s own tooling show. SEA is young, native addons need a compiler, and WebAssembly sidesteps both.
How SEA is built
SEA is a stability 1.1, “active development”, feature in the Node 26 docs, so details change between releases. In Node 25.5 and later, there is a one-step build flag. The documented flow:
echo 'console.log(`Hello, ${process.argv[2]}!`);' > hello.js
echo '{ "main": "hello.js", "output": "sea" }' > sea-config.json
node --build-sea sea-config.json
./sea World
The config file can also list assets, extra files you embed, and options such as useSnapshot and useCodeCache for faster startup. Inside the executable, require('node:sea') gives you sea.isSea() to detect that you are running as an executable and sea.getAsset(name, encoding) to read an embedded asset. Guides written before 25.5, including the conference talk, use a two-step flow: generate a blob with --experimental-sea-config, then inject it into a copy of the binary with a tool called postject. The idea is the same, and the newer flag does both steps.
I could not run this end to end here, and that is part of the lesson. On my machine, Node 26.13.1 installed from Homebrew answered node --build-sea sea-config.json with Single executable application is disabled. That build links Node as a shared library, and SEA needs a Node binary built to support it. Official release binaries from nodejs.org are the usual route. I did not download one, so the commands above come from the Node 26 documentation and are not something I ran. If you try this, confirm your Node supports it before debugging your config.
Practical constraints to plan around:
- One script. SEA embeds a single entry file, CommonJS or an ES module. Bundle your app and its dependencies into that file first with a bundler such as esbuild, so nothing needs to be found in
node_modulesat run time. - Assets are explicit. Templates, JSON or binary files go in the
assetsmap and are read withsea.getAsset(), not withfsand a relative path. - Size. The output includes the whole Node binary. The Homebrew
nodefile on my machine was 130 KB only because it loads a shared library, and a standalone binary will be many tens of megabytes. Expect that for every platform you ship. - Per platform builds. You build on each operating system and CPU architecture you target, and macOS and Windows may require the result to be code-signed.
- No automatic updates. A security fix in Node means rebuilding and redistributing.
Other routes exist for the same goal, including bundling Node with tools like pkg forks and other runtimes’ compile features, which are covered in Node.js vs Deno and Bun. SEA’s advantage is that it is part of Node and tracks it.
Native addons
Sometimes JavaScript is not enough: you need a C library, a system API or raw speed. A native addon is compiled code that Node loads like a module:
const addon = require('./addon.node');
addon.add(2, 3); // 5
The modern way to write one is against Node-API (N-API), a C interface that is stable across Node versions. Here is a minimal addon, which I compiled and ran against Node 26:
#include <node_api.h>
static napi_value Add(napi_env env, napi_callback_info info) {
size_t argc = 2; napi_value args[2];
napi_get_cb_info(env, info, &argc, args, NULL, NULL);
double a, b;
if (argc < 2 || napi_get_value_double(env, args[0], &a) != napi_ok
|| napi_get_value_double(env, args[1], &b) != napi_ok) {
napi_throw_type_error(env, NULL, "add(a, b) needs two numbers");
return NULL;
}
napi_value result; napi_create_double(env, a + b, &result);
return result;
}
NAPI_MODULE_INIT() {
napi_value fn;
napi_create_function(env, "add", NAPI_AUTO_LENGTH, Add, NULL, &fn);
napi_set_named_property(env, exports, "add", fn);
return exports;
}
I built it with Apple’s clang directly, pointing at the headers that came with my Node install: clang -shared -undefined dynamic_lookup -DNAPI_VERSION=8 -I<node>/include/node addon.c -o addon.node. Then addon.add(2, 3) returned 5, and addon.add('x') threw TypeError: add(a, b) needs two numbers. That is all an addon is: a shared library exporting an init function, loaded with require. Real projects do not call clang by hand. They use node-gyp, which reads a binding.gyp file, downloads the right Node headers and drives the platform’s compiler. I did not run node-gyp, so treat its usage as documented, not tested.
Three practical points:
- Prefer Node-API. An addon written against V8’s C++ API breaks when V8 changes and has to be rebuilt per Node version. A Node-API addon built once keeps working across versions. The C++ wrapper
node-addon-apimakes it more pleasant to write. - Compilers are a real cost. Anyone installing your package from source needs Python, a C/C++ toolchain and matching headers, which is where many
npm installfailures come from. Packages avoid this by shipping prebuilt binaries for each platform. - Addons run with your full privileges. They are native code in your process, so they are a bigger supply-chain risk than JavaScript, as in securing Node dependencies and the supply chain. Under
--permission, they need--allow-addons, in the permission model.
WebAssembly as the alternative
If you want compiled speed without a toolchain per platform, WebAssembly is often simpler. Node runs it with the same WebAssembly API as the browser:
// (module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add))
const bytes = new Uint8Array([0,97,115,109,1,0,0,0,1,7,1,96,2,127,127,1,127,3,2,1,0,7,7,1,3,97,100,100,0,0,10,9,1,7,0,32,0,32,1,106,11]);
const { instance } = await WebAssembly.instantiate(bytes);
console.log(instance.exports.add(2, 3)); // 5
console.log(instance.exports.add(2147483647, 1)); // -2147483648: it is a 32-bit integer add
That ran as written. In practice you compile Rust, C or Go to a .wasm file and load it the same way. The module is portable across operating systems and CPUs, and it is sandboxed, since it can only call what you import into it. It is slower than a native addon on tight loops and cannot use system APIs directly, but WASI, node:wasi, exists for file-like system access. It was still printing an ExperimentalWarning in Node 26.
Choosing
- Distributing a CLI to people without Node: SEA, or a bundler plus a normal
npm install -gif your users have Node. - Calling an existing C library or a platform API: a Node-API addon, with prebuilt binaries.
- Fast, portable compute: WebAssembly first.
- A service you control: skip all three and use the deployment options from the previous lesson.
What the video covers
The embedded talk is Edouard Maleix’s “Building Single Executable Applications with Node.js” from Vendure Conf 2024, uploaded in December 2024. Its description is one sentence: it presents the new set of Node.js APIs for building and distributing Node applications as single executables. It covers SEA only, not Node-API, node-gyp or WebAssembly, which this lesson carries. It was recorded before the --build-sea flag arrived in Node 25.5, so its build steps are the older two-step flow. It comes from a small channel, its transcript was not available, and I’m describing it from its title and description alone.
Where this fits
This ends the Node.js roadmap. From here, the useful next steps are depth in whichever area your work leans on: Express and Fastify services, streams or worker threads for performance, and the backend roadmap for the architecture around any of it.
Check yourself
What does a single executable application let you ship that a normal Node project does not?
One file that runs on a machine without Node or `npm install`. Node copies its own binary and injects a blob containing your bundled script and assets, and at startup the binary notices the blob and runs it instead of acting as the ordinary `node` command. It suits CLIs and tools distributed to users who should not need a Node setup.
Why do you bundle your application before building a SEA?
The SEA mechanism embeds a single script as the entry point. If your code `require`s or `import`s other files and `node_modules`, those are looked up on disk at run time and will not exist on the target machine. Bundling with a tool such as esbuild puts all JavaScript into one file, and extra data files go in as assets read with `sea.getAsset()`.
What is Node-API, and why prefer it to writing an addon against V8 directly?
Node-API (`node_api.h`, historically N-API) is a C interface to Node that stays ABI-stable across Node versions. An addon compiled against it keeps working when Node upgrades, while an addon written against V8 internals breaks whenever V8 changes and must be rebuilt for each version. Wrappers such as `node-addon-api` give a friendlier C++ layer over it.
When would WebAssembly be a better choice than a native addon?
When you want the same compiled code to run on any OS and CPU, in Node and in browsers, with no per-platform build, no install-time compiler and a sandbox that cannot touch the file system or network unless you pass it in. A native addon is faster for tight loops and can use system APIs, but needs a toolchain or a prebuilt binary per platform.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.