Node.js Single Executable Applications

Node.js Tutorials


Single executable applications (SEA) package a Node.js entry script with the Node.js runtime. The resulting program runs on a compatible machine without a separate Node.js installation.

This walkthrough uses Node.js 25.5 or later, where --build-sea builds the executable directly. SEA remains an active-development feature; check the runtime used for the build.

Create the Entry Script

Save this as app.cjs in a new working directory:

Example:

console.log('Hello from a Node.js executable');

Create the Build Configuration

Save this as sea-config.json:

Example:

{
  "main": "app.cjs",
  "mainFormat": "commonjs",
  "output": "hello-sea",
  "useSnapshot": false,
  "useCodeCache": false
}

On Windows, change the output to hello-sea.exe. Here output names the final executable, not a preparation blob.

Build and Run

Example:

node --build-sea sea-config.json
./hello-sea

On Windows PowerShell, run .\hello-sea.exe instead of ./hello-sea.

Output:

Hello from a Node.js executable

The executable normally targets the platform and architecture of the Node binary used to build it. Build and test separately for each deployment target. Platform signing requirements may also apply before distribution.

Older Node.js Workflows

Earlier SEA-capable releases use --experimental-sea-config to create a preparation blob, followed by a separate resource-injection step. That command does not itself create the distributable executable. Do not mix its blob configuration with the newer direct-build workflow.

Dependencies and Assets

The embedded entry can be CommonJS or an ES module; mainFormat selects the format. CommonJS is used here for simplicity. A project with multiple files or package dependencies generally needs a bundling step because embedded module loading is not the same as loading an ordinary project directory. Built-in modules remain available.

Additional data such as templates can be included as SEA assets. Code-cache and snapshot settings impose further compatibility constraints, so they are disabled in this introductory build.

This example requires command-line access and creation of an executable. A browser JavaScript compiler cannot perform the full build-and-distribute workflow.

Conclusion

The key distinction is between older blob generation and newer direct executable building. With a compatible runtime, a small entry script and SEA configuration are enough to build and test a standalone tool.



Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram