To create an stand-alone executable from a NodeJS project the process is as follows:
-
Install
pkg
usingnpm i -g pkg
-
If the project does not have dynamic requires use
pkg entryPoint.js
-
If the project has dynamic imports add the following code to your
package.json
"pkg": {
"scripts": "someDirectory/*.js"
}
-
Then execute
pkg package.json
-
Chmod the executables using
chmod +x
On linux the binary can be added to bin
and then made globally executable using chmod a+rx
.