将Node.js应用程序打包为OS X应用程序 [英] Package a Node.js application as an OS X application
问题描述
我想为一系列终端命令构建一个接口,供我们的开发人员用来管理其开发环境.我想尝试在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.
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.
之所以这样做,是因为我需要访问本地系统,以便能够配置许多东西并与任意数量的运行中(无头VM)进行交互.因此,我不能简单地从服务器上提供服务并让他们访问该网站.
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.
有什么想法吗?
推荐答案
选项1:电子(又名原子-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:来自Node的 Carlo chrom(ium)壳.
Option 3: Carlo chrom(ium) shell from Node.
这将使您可以将本地安装的Chrome启动为可连接到本地运行的服务器应用程序的外壳.它确实需要本地镀铬,但与要求的镀铬非常接近.
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)
具有Node集成的MacGap(似乎已经过时了)
MacGap with Node integration (Seems to be getting stale)
除了:服务...
我不能以此为OSX来代表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-陈旧/未维护 -
AppJS-已替换为DeskShell -
DeskShell-陈旧,网站离线 -
node-webkit-重命名为NW.js -
XULRunner项目停滞了,并且远远落后 -
推力(
nexe- stale/unmaintainedAppJS- replaced with DeskShellDeskShell- stale, website offlinenode-webkit-renamed to NW.jsXULRunnerproject 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
这篇关于将Node.js应用程序打包为OS X应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!