70

I am considering developing a desktop application composed of 2 parts:

  • user interface (Java app for example)
  • back-end Node.js server

The 2 parts connect through sockets. Don't ask why I know it's weird.

I will want to be able to provide to customers the application with an installer. I don't want that users have to install Node.js themselves.

Is there a way to have a Node.js server installed as standalone, i.e. no need to install Node.js globally on the system.

This is a question for any (Windows, Linux, Mac OS X...) environment.

Matthieu Napoli
  • 45,472
  • 43
  • 162
  • 249
  • 2
    A relevant question: http://stackoverflow.com/questions/8794140/is-it-possible-to-create-desktop-applications-with-node-js – Anderson Green Nov 15 '12 at 06:33
  • 4
    This appears to be part of a Duplicate Pool: http://stackoverflow.com/questions/6145561/is-there-a-way-to-compile-node-js-source-files, http://stackoverflow.com/questions/7557364/packing-node-js-scripts-node-exe-into-a-single-executable, http://stackoverflow.com/questions/8173232/make-exe-from-node-js-app, http://stackoverflow.com/questions/8794140/is-it-possible-to-create-desktop-applications-with-node-js, http://stackoverflow.com/questions/9724817/how-to-create-a-stand-alone-command-line-application-with-node-js, http://stackoverflow.com/questions/13388108/standalone-node-js-application – Mogsdad Mar 10 '13 at 12:51
  • possible duplicate of [How do I deploy Node.js applications as a single executable file?](http://stackoverflow.com/questions/14314038/how-do-i-deploy-node-js-applications-as-a-single-executable-file) – Artjom B. Jul 31 '15 at 17:41
  • @ArtjomB. The question you linked to is 1 year older than mine. And [this question](http://stackoverflow.com/questions/7557364/packing-node-js-scripts-node-exe-into-a-single-executable) is specifically for Windows, which isn't answering my question. – Matthieu Napoli Aug 03 '15 at 11:00

6 Answers6

37

Update 2017-05-04: And there's a new kid in town:

Update 2016-11-14: Nowadays Electron and nwjs seem like the best options.

Original:

There are a number of steps you have to go through to create an installer and it varies for each Operating System. For Example:

coolaj86
  • 69,448
  • 16
  • 99
  • 116
18

You can bundle the binaries with your application. Won't have to install anything to run a Node app. The binaries are available on the same page as the installers.

You'll just have to know where the binaries are, but I assume you've got an installer that can put them somewhere known.

// To start the node process
$ /path/to/binaries/npm install
$ /path/to/binaries/node myApp.js
BadCanyon
  • 2,837
  • 16
  • 17
  • Is such packaging legal according to nodejs license? – Pacerier Oct 30 '17 at 21:42
  • 2
    it doesn't answer the question – Vyachaslav Gerchicov Jun 11 '18 at 14:56
  • This answer is outdated/incomplete, there is now a bunch of tools to handle this (see [@CoolAJ86's answer](https://stackoverflow.com/a/18703421/1439688)). Just tried [`pkg`](https://www.npmjs.com/package/pkg) on macOS, it generates one standalone executable file per platform, I tested the `.exe` on an out-of-the-box windows VM, works flawlessly. – zakinster Jan 03 '19 at 14:08
9

Node-Webkit is an option, but it really isn't set-up to do a "server - client" type relationship.

Another option is packaging the node.js installers with you application installer. Then when the application boot you can spin up a node.js process. I know some developers have been doing this with titanium, here is a little bit more information information.

Hope this helps!

Sdedelbrock
  • 4,834
  • 1
  • 17
  • 13
  • 2
    You can launch a server from node-webkit just in the way you launch it in Node.js. It's just that node-webkit provide another way beyond B/S architecture. – Roger Wang Nov 15 '12 at 08:17
  • This doesn't directly answer my question (so I've accepted another one) but this is awesome this is an even better solution that what I was planning to do!! Thank you!! – Matthieu Napoli Nov 15 '12 at 09:00
  • @RogerWang Could you explain how to launch a server from node-webkit – Premalatha Jun 25 '19 at 10:58
4

Here's an option: Light Table is a node app, but installs nicely and integrates the GUI (webkit) cleanly on most OSs.

To do this it leverages node-webkit. (Runs node code straight from an html page.) Here is the packaging documentation.

brandonscript
  • 62,971
  • 29
  • 152
  • 211
rdrey
  • 8,971
  • 3
  • 38
  • 50
3

Worth mentioning Electron made by GitHub. Used for building Atom, Slack, Visual Studio Code and more.

itamarb
  • 2,529
  • 3
  • 28
  • 35
1

I’ve just stumbled upon nexe – a tool which “creates a single executable out of your node.js app”.

I haven’t tried it out yet, but I guess that even works without an installer – producing just a single standalone binary.

tomekwi
  • 1,898
  • 1
  • 19
  • 23
  • 2
    Just tried using it. Had a lot of problems. It would fail silently a lot. I never got it working in some of my use cases so I switched to pkg mentioned above and had to problems. – Sobachatina Jan 24 '18 at 23:39