node-exe-compile
is a small config based wrapper for @yao-pkg/pkg (fork of vercel's pkg package)
it is using esbuild to minify and bundle the script specified in the config file, then using pkg
it compiles to an exe
file
This package is not well tested, and may not work as expected, use at your own risk, the package was tested on Windows and Linux, but may not work on other platforms
-
Install the package
npm install -D @energypatrikhu/node-exe-compile
-
Add the following scripts to your
package.json
{ "scripts": { "compile": "node-exe-compile" } }
-
Start the script
this creates an example configuration file, that later can be modified to set the compiled name and others..
npm run compile
-
After that is done, you have to start
node-exe-compile
againnow the script minifies and then compiles the given script to an executable
npm run compile
The generated configuration file is almost identical to the default configuration file needed for the pkg
package, with a few additions
-
name
: the name of the file after compiling -
main
: this is the location of the main file, commonlysrc/index.[ts,js]
-
bin
: the path to the minified and bundled script (this most of the times does not need to be changed) -
autoCopy
: this is a boolean value, if set totrue
it will copy the needed files to the output directory -
pkg
: pkg options-
targets
: NodeJS version (latest == node20) -
assets
: when using packages that has.node
extension the value has to be set, otherwise it may fail to start -
outputPath
: the path where the executable will be built -
additional
: this contains the additional settings forpkg
-
compress
: the compression used at complile time - ...
-
-