Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sea-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"main": "build.cjs",
"output": "sea-prep.blob"
}
48 changes: 48 additions & 0 deletions single-exec-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
npx esbuild bin/index.js --bundle --outfile=build.cjs --format=cjs --platform=node

# Single executable applications (https://nodejs.org/api/single-executable-applications.html)
# This feature allows the distribution of a Node.js application conveniently to a system that does not have Node.js installed.

# 3. Generate the blob to be injected

node --experimental-sea-config sea-config.json

# 4. Create a copy of the node executable and name it according to your needs

cp $(command -v node) guida

# node -e "require('fs').copyFileSync(process.execPath, 'hello.exe')" # On windows

# 5. Remove the signature of the binary (macOS and Windows only)

codesign --remove-signature guida # On mac

# signtool remove /s guida.exe # On Windows (optional)

# 6. Inject the blob into the copied binary by running postject with the following options

# Linux
# npx postject guida NODE_SEA_BLOB sea-prep.blob \
# --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2

# On Windows - PowerShell
# npx postject guida.exe NODE_SEA_BLOB sea-prep.blob `
# --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2

# On Windows - Command Prompt
# npx postject guida.exe NODE_SEA_BLOB sea-prep.blob ^
# --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2

# On macOS
npx postject guida NODE_SEA_BLOB sea-prep.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
--macho-segment-name NODE_SEA

# 7. Sign the binary (macOS and Windows only)

# On macOS
codesign --sign - guida

# On Windows (optional)
# A certificate needs to be present for this to work. However, the unsigned binary would still be runnable.
# signtool sign /fd SHA256 guida.exe