Can I make Node.JS app self executable? [duplicate

2019-09-11 01:29发布

问题:

This question already has an answer here:

  • How to make exe files from a node.js app? 16 answers
  • Packing Node.js-Scripts + node.exe into a single Executable [duplicate] 3 answers

I'm a Node.JS beginner, so please forgive me if my question is too naive or too simple:) I made myself a simple node.js app: index.js which requires my_module.js. The second one just displays console.log("Hello").

Now I would like to pack it somehow into single exe file (I work on Windows) to be able to run it on another machine without the need of having node installed. Is that even possible?

回答1:

The core problem was already answered from here I will provide some specifics on Windows in addition to answer.

basically;

  1. Download and Install JXcore
  2. Go to your apps folder
  3. Run 'jx package index.js myapp -native'

Be careful with the executable you have. If you are on 64 bit Windows, you will end up having a 64 bit executable of your application. Perhaps almost all the Windows installations nowadays are 64 bits and this won't be a big deal. However you can also have a 32 bit version by re-packaging the app on 32 bit Windows. AFAIK the upcoming update to JXcore will be handling this confusion.



回答2:

I wrote a blog post on this here:

http://www.alexjamesbrown.com/blog/development/create-a-standalone-exe-to-run-a-node-js-application/