将Node.js应用程序打包为osx应用程序

将Node.js应用程序打包为osx应用程序

问题描述:

我想为我们的开发人员用来管理他们的开发环境的一系列终端命令构建一个接口。我想尝试在node.js中构建它。

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.

现在,我想我可以使用express创建它作为HTML5 / CSS3 / JS应用程序,等...然后想把它打包成一个原生的osx应用程序。意思是,我可以发送它们的应用程序,他们双击并运行但是要么启动Chrome浏览器并导航到localhost:命中脚本的端口服务器,或者只是启动服务器并指示用户转到URL 。无论哪种方式都没问题。

Now, I'm thinking I can create it as an HTML5/CSS3/JS application using express, etc... and then would like to package it as a native osx app. Meaning, an app 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.

任何想法?

谢谢,

Luis

选项1: electron (又名atom-shell)

Option 1: electron (aka atom-shell)

这是github的Atom编辑器使用的shell。它与node-webkit非常相似,但它首先运行脚本,你必须为用户创建一个视图/窗口。还有其他一些细微差别,但值得一看。

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.

选项2: NW.js 以前的node-webkit

Option 2: NW.js formerly node-webkit

要点是它基本上扩展了JS引擎你编写一个支持节点的扩展对象模型和模块的基于Web的应用程序...然后你将package.json start.html模块和js文件打包成一个zip(扩展名为.nw)并用nw(。 exe)..有windows,mac和linux版本可用。

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.

选项3: Carlo chrom(ium)shell。

Option 3: Carlo chrom(ium) shell from Node.

这将允许你启动本地安装的Chrome作为shell,可以连接到本地运行的服务器应用程序。它确实需要本地镀铬,但非常接近要求。

This will allow you to launch the locally installed Chrome as a shell that can connect to a locally running server application. It does require a local chrome, but is very close to what was asked for.

选项4: MacGapNode (仅限OSX)

Option 4: MacGapNode (OSX Only)

带节点集成的MacGap (似乎变得陈旧)

MacGap with Node integration (Seems to be getting stale)

旁白:服务......

Aside: Services...

我不能以此作为.App来代表OSX,但很可能在NodeJS中创建后台服务安装,并在桌面上创建指向本地站点的链接。大多数浏览器都有一个不显示所有功能的选项(特别是我知道firefox)。

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).

我知道你的问题特别针对OSX,但在windows中你可以使用NSSM作为服务运行任何东西,我已经在Windows中将它用于基于NodeJS的服务。我认为上面的一些其他选项会更好,具体取决于您的需求。

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.

已移除:

  • 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

这个答案是为多个问题复制的,这些引用主要是为了方便更新。

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

  • Packaging a node.js webapp as a normal desktop app [closed]
  • Package a Node.js app as an osx app