Home » Javascript » Packaging a node.js webapp as a normal desktop app [closed]

Packaging a node.js webapp as a normal desktop app [closed]

Posted by: admin December 5, 2017 Leave a comment

Questions:

I’ve searched a bit but 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 aswesome if I could double click MySnazzyThing.app instead of installing nodejs, and npm and running node mysnazzyapp.js on the command line.

The .app executable would spool up the node 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 app could then, say, be distributed through the mac app store. And bam, a node.js desktop app.

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

Answers:

You can accomplish this using AppJS: https://github.com/appjs/appjs

Questions:
Answers:

Option 1: electron (aka atom-shell)

This is the shell that github’s Atom editor uses. 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 JS engine for you to write a web-based app supporting node’s extended object model, and modules… you then package your package.json start.html modules and js files into a zip (with the .nw extension) and run it with nw(.exe) .. there are windows, mac and linux builds available.


Option 3: Thrust (Node Adapter)

This is a really lose binding around webkit/chrome with an ipc channel to a launching application. You can either use the message channel, or you can write your app as a more traditional server-side app in node, and control a window launch. Which may suite you well.

Thrust has bindings for multiple languages. I put this ahead of MacGapNode only because I’m favoring cross-platform options first.


Option 4: MacGapNode (OSX Only)

MacGap with Node integration (Seems to be getting stale)


Aside: Services…

I can’t speak for OSX on this as a .App, but it could well be possible to create a background service install in NodeJS 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 OSX in particular, but in windows you can use NSSM to run anything as a service, and I have used it for NodeJS 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, these references are mostly for updating convenience.

Questions:
Answers:

I suggest looking into Topcube, it’s goal is to “Give node developers a way to have a desktop GUI to their node servers using HTML5 + CSS3 as the GUI platform.” Topcube at github.

Questions:
Answers:

Currently there are a plethora of ways to accomplish this.

The clear winner in the space of packaging a node + html5 app, is currently Electron (used by Atom, VSCode, Slack, Discord, etc).

You can also use any other language packaged as an app (using tools for those languages/stacks), and check for a node installation, launch the “server” script with node, then launch the default browser (or some web view component, by some other means), finally set location to the node service. This is a very light weight 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.

https://electron.atom.io/
https://nwjs.io/

Questions:
Answers:

Can’t you do this with a bash script? I don’t know enough to provide the details, but that’s probably the way to go.

Leave a Reply

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