Create a standalone EXE to run a Node.js application

Download Advanced BAT to EXE converter

Download Node.exe from Joyent

Now we’re ready to bundle the node.js executable and our js files into a single exe file.

As for our BAT command, all we need is:

BAT Command

node test.js

%MYFILES% is the variable given to the location of embedded files (more on that in a sec)

Your Advanced BAT to EXE converter window should look like the image on the left.

Don’t worry about bundling the files together just yet, we’ll do that in a sec.

For the purposes of this demo, I’ve created a very simple test.js file, that looks like this:

for(i=1;i<=10000;i++) { 

Save that .js file locally.

Now, from the File menu, select Build Exe (CTRL+ B)

Enter a filename for the final exe file.

EXE Options

Next, the EXE options pane will be displayed.

Click the Embed Files tab, and select both your node.exe and test.js files.

Set any other options you feel you’ll need here.

Then, simply click Build EXE.

Your executable will be bundled and in the location you chose to save it.

Run it, and you’ll have 1-10000 outputted into the console.

9 responses to “Create a standalone EXE to run a Node.js application”

  1. Clint avatar

    The only problem I have found is if I want to include node_modules. I can’t package those inside the exe. Do you keep them in a visible folder?

    1. Alex avatar

      Hmm.. an interesting one. Yeah, I think putting them in a ‘lib’ folder and referencing them that way would work… Haven’t tried that yet though

    2. Alex Brown avatar

      Are you still having this issue? I can’t seem to reproduce it?

  2. Igor avatar

    Hi Alex! Sorry for noobish question, but please answer:)
    In your post you wrote:
    “%MYFILES% is the variable given to the location of embedded files (more on that in a sec)”
    Probably you forgot to add it later… What should I write instead of “CD %MYFILES%/”? I tried an absolute path to my .js script and it worked on development machine. But when I put this .exe on other computer (without Node) and call it in the same way, nothing happens (it gives me a current folder of the calling programm in a command prompt and nothing else happens)…
    So, could you please hint me what should I do to have exe that I can distribute to other computers?

  3. Alden Quimby avatar

    Very helpful article! Any chance you could update the example to include the node_modules folder?

    1. Alex avatar

      It’s a long time since I worked on this, will try and have a look!

  4. nobo avatar

    It’s better not to use this all together, the output *.exe contains trojan upon creation.

    1. Alex avatar

      what are you talking about?

  5. Shubham Verma avatar
    Shubham Verma

    Thanks Alex.
    its Worked.
    Thank you so much.. You saved my time.

Leave a Reply

Your email address will not be published. Required fields are marked *