85

I've searched a bit, but I can't find an existing tool for this.

I have a Node.js web server that is designed to run on your own computer that does some snazzy things for you. It would be pretty awesome if I could double click MySnazzyThing.app instead of installing Node.js, and npm and running node mysnazzyapp.js on the command line.

The .app executable would spool up the Node.js server and open a simple native WebKit window which would show what would normally be on localhost:3000 if I were running on the command line.

This native application could then, say, be distributed through the Mac App Store. And bam, a Node.js desktop application.

Does any such tool exist? Or are there any technical reasons that this wouldn't work as I imagine it?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alex Wayne
  • 178,991
  • 47
  • 309
  • 337

4 Answers4

94

Option 1: Electron (formerly atom-shell)

This is the shell that GitHub's Atom and Microsoft's Code editors use. It’s very similar to node-webkit, though it will run the script first, and you have to create a view/window for the user. There are some other minor differences, but it's worth looking at.


Option 2: NW.js formerly node-webkit

The gist is that it basically extends the JavaScript engine for you to write a web-based application supporting Node.js' extended object model, and modules... you then package your package.json start.html modules and JavaScript files into a ZIP file (with the .nw extension) and run it with nw(.exe) .. there are Windows, Mac and Linux builds available.


Option 3: Neutralinojs Github

Neutralinojs is a lightweight and portable desktop application development framework. It lets you develop lightweight cross-platform desktop applications using JavaScript, HTML and CSS. You can extend Neutralinojs with any programming language (via extensions IPC) and use Neutralinojs as a part of any source file (via child processes IPC).


Option 4: MacGapNode (OS X only)

MacGap with Node.js integration (it seems to be getting stale)


Option 5: Tauri Github

Tauri is a toolkit that helps developers make applications for the major desktop platforms - using virtually any frontend framework in existence. The core is built with Rust and the CLI leverages Node.js making Tauri a genuinely polyglot approach to creating and maintaining great apps.


Aside: Services...

I can't speak for OS X on this as a .App, but it could well be possible to create a background service install in Node.js and a link to a "local" site on the desktop. Most browsers have an option to not show all the features (I know Firefox in particular does).

I know your question is to OS X in particular, but in Windows you can use NSSM to run anything as a service, and I have used it for Node.js-based services in Windows. I think some of the other options above are better depending on your needs though.


Removed:


This answer is copied for multiple questions, and these references are mostly for updating convenience.

Tracker1
  • 19,103
  • 12
  • 80
  • 106
  • 1
    For OSX and Linux https://github.com/crcn/nexe also looks like a solution. – robocat Mar 12 '13 at 02:53
  • It looks like node-webkit is the winner among these. Large developer base, good documentation, backed by Intel. – Dan Jun 26 '13 at 04:57
  • gerty, thanks... I updated my answer to include nexe, as well as made node-webkit the top spot... looks like appjs may be getting a little stale. – Tracker1 Jun 26 '13 at 18:02
  • For OSX checkout Macgap so you can submit to app store. Node webkit gets denied for using a potentially outdated api in the future. – Michael J. Calkins Dec 28 '13 at 05:45
  • Hmm, now there's an idea. Run the app as server in the background, then just open a browser window for it (e.g. [How can I launch a browser with no window frame or tabs/address bar](http://superuser.com/q/459775/83682)). You don't get quite as much control over the window that way (e.g. the browser handles the menu items like file, edit, view, etc, and the user still has access to things like the browser's print, zoom, and in-page search functions), but there's basically no extra framework required. – Ajedi32 Feb 09 '15 at 22:06
  • It's very easy to work with Electron, but there's a big downside for building OSX apps, the file size will be at least 100mb. – Gene Parcellano Dec 17 '17 at 06:26
  • Its worth mentioning [pkg](https://github.com/vercel/pkg) module for this – jignesh kumar Jan 30 '22 at 09:10
  • @jigneshkumar thanks, I'll take a look and likely insert at #4, also need to edit down the marketing copy/paste for tauri. – Tracker1 Feb 04 '22 at 00:09
22

You can accomplish this using AppJS.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Motin
  • 4,853
  • 4
  • 44
  • 51
  • 6
    splash page for AppJS project now points to deskshell: https://github.com/sihorton/appjs-deskshell/ – yzorg Jan 08 '14 at 12:51
  • 2
    As @Tracker1's answer indicates, deskshell is now a stale project & hasn't been developed since dec 2013 – cmroanirgo May 23 '15 at 22:33
8

I suggest looking into Topcube. Its goal is to give Node.js developers a way to have a desktop GUI to their Node.js servers using HTML5 + CSS 3 as the GUI platform.

Topcube at GitHub.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Brian Heese
  • 654
  • 5
  • 9
  • 1
    Topcube doesn't seem to be supported much longer – Shamoon Nov 16 '11 at 16:53
  • Yes, i suggest looking into Titanium. It's not Node.js but is JS based and cross platform for PC and mobile application development. http://www.appcelerator.com/products/titanium-cross-platform-application-development/ – Brian Heese Dec 13 '11 at 12:00
  • That Titanium link has rotted. I suppose this one is what you're referring to: http://docs.appcelerator.com/titanium/2.0/index.html Their opaque marketing-heavy website sure does make it hard to see what their product is, or to care. – Grumdrig Apr 25 '12 at 21:41
  • Note: The Titanium desktop parts are not going to be developed/supported anymore. – Sri Kadimisetty Oct 06 '12 at 15:32
  • 1
    Titanium Desktop development has been taken up over by a new group of developers: http://www.tidesdk.org – Motin Nov 26 '12 at 10:52
0

Currently there are a plethora of ways to accomplish this.

The clear winner in the space of packaging a Node.js + HTML5 application, is currently Electron (used by Atom, Visual Studio Code, Slack, Discord, etc.).

You can also use any other language packaged as an application (using tools for those languages/stacks), and check for a node installation, launch the "server" script with Node.js, then launch the default browser (or some web view component, by some other means), finally set location to the Node.js service. This is a very lightweight and efficient method, however not as well integrated with the OS as a solution like Electron.

The primary competitor to Electron here, is NW.js. As far as I can tell, the main feature that NW.js has that Electron does not (yet) is compilation/obfuscation. While Electron makes auto updates easy.

Tracker1
  • 19,103
  • 12
  • 80
  • 106
Dev
  • 162
  • 5