I have a node app that I wrote, that I run as follows:
node.exe app.js inputArg
Is there some way I can package this into a .exe by itself? So I can just do something like this?
App.exe inputArg
I have some way of faking this by using a batch file, so I can do this:
App.bat inputArg
But this requires that I have all the dependencies and node in that folder, which is not ideal.
Bit late on this, but based on the answer, I created a quick "how-to" blog post, using Advanced" Batch To EXE Converter
http://www.alexjamesbrown.com/development/create-a-standalone-exe-to-run-a-node-js-application/
Try nexe which creates a single executable out of your node.js apps
https://github.com/nexe/nexe
I'm recommending you BoxedApp for that. It is a commercial product that working very well. It works for any NodeJS app. The end-user will get just one EXE file for your app. No need for installation.
In Electron, for example, the end user needs to install/uncompress your app, and he will see all the source files of your code.
BoxedApp It is packaging all the files and dependencies that your NodeJS app needs. It supports compressions, and the compiled file works on Windows XP+
When you use it, be sure to add Node.EXE to the compiled app. Choose a node version that supports Windows XP (If you need this)
The program supports command line arguments, So after package, you can do
And you can get the argument in your node code:
Sometimes your app has files dependencies, so in BoxedApp you can add any folder and file as a dependency, for example, you can insert a settings file.
More info:
There may be many other options but to my knowledge, there is one project in active development on GitHub https://github.com/zeit/pkg. You can play with it. One more at https://github.com/nexe/nexe but not in active development.
I've been exploring this topic for some days and here is what I found. Options fall into two categories:
If you want to build a desktop app the best options are:
Here is a good comparison between them: NW.js & Electron Compared. I think NW.js is better and it also provides an application to compile JS files. There are also some standalone executable and installer builders like Enigma Virtual Box. They both contain an embedded version of Chrome which is unnecessary for server apps.
if you want to package a server app these are the best options:
In this category, I believe node-compiler is better which supports dynamic require and native node modules. It's very easy to use and the output starts at 25MB. You can read a full comparison with other solutions in Node Compiler page. I didn't read much about Nexe, but for now, it seems Node Compiler doesn't compile the js file to binary format using V8 snapshot feature but it's planned for version 2. It's also going to have built-in installer builder.