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.
The solution I've used is Roger Wang's node-webkit.
This is a fantastic way to package nodejs apps and distribute them, it even gives you the option to "bundle" the whole app as a single executable. It supports windows, mac and linux.
Here are some docs on the various options for deploying node-webkit apps, but in a nutshell, you do the following:
Just as an added note - I've shipped several production box/install cd applications using this, and it's worked great. Same app runs on windows, mac, linux and over the web.
For anyone stumbling upon this question, there are now two projects that create exes out of your node projects, EncloseJS and Electron.atom.io , they differ slightly:
The resulting executable is Windows ONLY ( .exe ).All platforms are supported now. It now requires a licence for commercial products.Got tired of starting on win from command prompt then I ran across this as well. Slightly improved ver. over what josh3736. This uses an XML file to grab a few settings. For example the path to
Node.exe
as well as the file to start in the default app.js. Also the environment to load (production, dev etc) that you have specified in your app.js (or server.js or whatever you called it). Essentially it adds theNODE_ENV={0}
where {0} is the name of your configuration in app.js as a var for you. You do this by modifying the "mode" element in the config.xml. You can grab the project here ==> github. Note in the Post Build events you can modify the copy paths to auto copy over your config.xml and the executable to yourNodejs
directory, just to save a step. Otherwise edit these out or your build will throw a warning.There is an opensource build tool project called nodebob. I assume that working platform windows,
You will find the executable file inside the release folder.
Since this question has been answered, another solution has been launched.
https://github.com/appjs/appjs
At the time of this writing, this is the end-all solution for packaging node.js apps through a stripped down chromium package compiled into an executable.
Edit: AppJS is no longer active, but itself suggests a fork called deskshell.
https://github.com/sihorton/appjs-deskshell/
There are a lot of good answers here, but they're not all as straightforward as JXcore.
Once you have JXcore installed on windows, all you have to do is run:
This will produce a .exe file that you can distribute and can be executed without any external dependencies whatsoever (you don't even need JXcore nor Node.js on the system).
Here's the documentation on that functionality: http://jxcore.com/packaging-code-protection/#cat-74
Edit 2018
That project is now dead but it is still hosted here: https://github.com/jxcore/jxcore-release (thanks @Elmue)