NW.js - Web 调用 Node 模块


MIT
跨平台
JavaScript

软件简介

NW.js 可以让你直接在 DOM 上调用所有 Node.js 模块,相当于使用一种新的方法来编写 Web 应用。NW.js 的前身是 node-
webkit

特性:

  • 使用 HTML5、CSS3、JS 和 WebGL 编写应用

  • 完全支持 Node.js APIs 以及其 第三方模块

  • 性能表现良好,Node 和 WebKit 运行在同一个线程,函数调用更直接,对象在同一个内存堆中,可直接引用

  • 方便打包和分发

  • 支持跨平台

演示程序:https://github.com/zcbenz/nw-sample-apps

示例:

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    We are using node.js <script>document.write(process.version)</script>.
  </body>
</html>

package.json:

{
  "name": "nw-demo",
  "main": "index.html"
}

运行:

$ /path/to/nw .  (suppose the current directory contains 'package.json')