nodejs-sea
v1.0.1
Published
A powerful package for NodeJS single executable applications (SEA), support good for NestJS framework
Downloads
162
Maintainers
Readme
Table of Contents
Description
This feature allows the distribution of a Node.js application conveniently to a system that does not have Node.js installed.
Node.js supports the creation of single executable applications by allowing the injection of a blob prepared by Node.js, which can contain a bundled script, into the node binary. During start up, the program checks if anything has been injected. If the blob is found, it executes the script in the blob. Otherwise Node.js operates as it normally does.
The single executable application feature currently only supports running a single embedded script using the CommonJS module system.
Users can create a single executable application from their bundled script with the node binary itself and any tool which can inject resources into the binary.
To use this CLI, you must use Node.js 18+.
API document
You can visit the full API documents in here
Installation
You can install the library using npm:
npm install nodejs-sea
With yarn
yarn add nodejs-sea
CLI usage
Run build script with npx
npx nodejs-sea sea
Options:
--version Show version number [boolean]
-s, --sea-config Path of the sea config file [string] [default: "sea/config.json"]
-n, --node-version Node.js version [string] [default: "*"]
-c, --clean Remove generated files [boolean] [default: true]
--help Show help [boolean]
Example
To build the single executable applications from source, please create the folder sea
, and put the config.json
file
{
"main": "sea/dist/server-out.js",
"output": "sea/dist/viactapp.blob"
}
If you want copy some files from your source to your build output, put them into copyFiles
{
"main": "sea/dist/server-out.js",
"output": "sea/dist/viactapp.blob",
"copyFiles": ["src/config.json", ".env"]
}
If you want run esbuild before, put esbuild config into esbuild
{
"main": "sea/dist/server-out.js",
"output": "sea/dist/app.blob",
"esbuild": {
"entryPoints": ["main.js"],
"bundle": true,
"outfile": "sea/dist/server-out.js",
"platform": "node",
"external": ["@aws-sdk/client-s3", "hbs"],
"packages": "bundle"
}
}
Contact and Feedback
If you have any ideas, comments, or questions, don't hesitate to contact me
Best regards,
Daniel Le
License
This library is licensed under the MIT License. See the LICENSE file for more details.