且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将Node.js应用程序打包为OS X应用程序

更新时间:2023-02-08 18:36:40

选项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 - 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