21

I want to build an interface for a series of terminal commands that our developers use to manage their development environments. I'd like to try to build it in Node.js.

Now, I'm thinking I can create it as an HTML5/CSS 3/JavaScript application using Express.js, etc... and then would like to package it as a native OS X application. Meaning, an application that I can just send them, they double click on and run, but that either launches a Chrome browser and navigates to the localhost:port server that hits the script or simply starts the server and instructs the user to go to the URL. Either way is fine.

I am doing this because I need access to the local system to be able to configure a number of things and interact with any number of running (headless VMs). So I can't simply serve this from a server and have them visit the site.

Any ideas?

4
  • Does this actually have to be a .app package? If not, it might be simpler to create a shell script that does all the launching stuff, and just call that MyApp.command, and package it alongside a local build of node and your source inside a zipfile or dmg or whatever. If it does need to be a .app, the simplest solutions will involve just directly launching the JS script, so you'll have to write the js code to launch the browser for the user (not that hard). If it needs to be a .app and you can't modify the JS, then you'll need to create a custom .app wrapper. So, which do you want?
    – abarnert
    Jun 12, 2012 at 19:41
  • 1
    PS, there is not (yet) a node.js equivalent to py2app, etc., that would make the intermediate solution really easy. From what I understand, appjs.org is the most promising option at this point, but the current release doesn't work on Mac… so you'll still have to do a good deal of work even if you go with the theoretically "easy" way.
    – abarnert
    Jun 12, 2012 at 19:42
  • PPS, also see groups.google.com/group/nodejs/browse_thread/thread/… (although that's more about bundling a WebKit GUI into the app, instead of launching the user's default browser).
    – abarnert
    Jun 12, 2012 at 19:44
  • Anyone know what the progress on this has been? Looks like appjs has been deprecated.
    – woodardj
    Apr 26, 2014 at 20:32

5 Answers 5

17

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.

6
  • @JasonJ.Nathan thanks, updated to remove thrust, and add Carlo in.
    – Tracker1
    May 13, 2019 at 22:16
  • Carlo is interesting in that it assumes Chrome is installed. Very interesting indeed :) May 14, 2019 at 9:57
  • Carlo is now officially unmaintained – might make sense to remove it from the list @Tracker1 (Source: github.com/GoogleChromeLabs/carlo/issues/…)
    – st_phan
    Jan 25, 2021 at 9:47
  • Tauri should be coming up on this list shortly
    – rx2347
    Feb 8, 2021 at 23:26
  • @st_phan deprecated carlo
    – Tracker1
    Nov 3, 2021 at 20:27
10

Here's a screencast + writeup on the subject of an installer (.pkg):

How to create an OS X pkg for NodeJS apps

As for the .app, I'm not sure yet, but I'm hot on the trail.

Also:

1
  • Can you summarise here? Those links may break at any time. Aug 14, 2021 at 15:46
3

Check out AppJS - "Build Desktop Applications for Linux, Windows and Mac using HTML, CSS and JavaScript"

It sounds like a good match :)

2
3

Check out NW.js - it's a project sponsored by Intel to package up Node.js applications for the desktop.

Specifically, see Creating Desktop Applications With node-webkit.

2

If you compile Node.js from source, every JavaScript file from Node.js' lib folder will be included into the binary. That same way could pack your code into the binary.

I am not familiar how Mac OS X packages are created, but at the end it does not seem to be very hard. Just pack your custom Node.js binary into one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.