Skip to content

Instantly share code, notes, and snippets.

@agmm
Last active May 27, 2020 19:42
Show Gist options
  • Save agmm/ed6384f79a8a6960a8b8987ed65e7c02 to your computer and use it in GitHub Desktop.
Save agmm/ed6384f79a8a6960a8b8987ed65e7c02 to your computer and use it in GitHub Desktop.
Stand-alone executable using pkg

To create an stand-alone executable from a NodeJS project the process is as follows:

  1. Install pkg using npm i -g pkg

  2. If the project does not have dynamic requires use pkg entryPoint.js

  3. If the project has dynamic imports add the following code to your package.json

 "pkg": {
  "scripts": "someDirectory/*.js"
}
  1. Then execute pkg package.json

  2. Chmod the executables using chmod +x

On linux the binary can be added to bin and then made globally executable using chmod a+rx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment