Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package a Node.js application as an OS X application

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?

like image 973
luisgo Avatar asked Jun 12 '12 19:06

luisgo


People also ask

How do I run a node js file on a Mac?

To write and run a NodeJS program on mac, first download and install the LTS version of NodeJS from its official website. After installation, create a new JavaScript(. js) file, write some code inside it, and run the “node fileName. js” command in the terminal.

How do I run a .js file on a Mac?

In the Shortcuts app on your Mac, double-click a shortcut. In the shortcut editor, click at the top of the action list, begin typing “Run JavaScript…” in the search field, then double-click the Run JavaScript on Active Safari Tab action to add it to the shortcut editor.


3 Answers

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:

  • nexe - stale/unmaintained
  • AppJS - replaced with DeskShell
  • DeskShell - stale, website offline
  • node-webkit - renamed to NW.js
  • XULRunner project stalled, and exceedingly behind.
  • Thrust (Node Adapter) - deprecated/stale
  • Carlo Chrom(ium) shell from Node.js. - unmaintained/stale

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

  • Packaging a Node.js web application as a normal desktop application
  • Package a Node.js application as an OS X application
like image 79
Tracker1 Avatar answered Oct 13 '22 14:10

Tracker1


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:

  • How to create a Node.js app .deb for Ubuntu Linux
  • How to create a Node.js app .exe for Microsoft Windows
like image 30
coolaj86 Avatar answered Oct 13 '22 15:10

coolaj86


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

It sounds like a good match :)

like image 38
Motin Avatar answered Oct 13 '22 14:10

Motin