【问题标题】:How to make Node Webkit work with express generator如何使 Node Webkit 与 express 生成器一起使用
【发布时间】:2016-07-23 05:56:26
【问题描述】:

我正在尝试使用快速生成器使用 Node 和 Express 制作应用程序,并使用 node-webkit 打包所有内容。 express 生成器创建了一个非常基本的应用程序,但它可以在 localhost:30000 上运行 npm start。

清单

{
  "name": "app",
  "version": "0.0.0",
  "private": true,
  "node-main": "./app.js",
  "main": "http://localhost:8080",
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.15.1",
    "bower": "^1.7.9",
    "cookie-parser": "~1.4.3",
    "debug": "~2.2.0",
    "express": "~4.13.4",
    "morgan": "~1.7.0",
    "pug": "^2.0.0-beta4",
    "serve-favicon": "~2.3.0"
  }
}

文件夹结构

当我使用 nwjs 运行应用程序时,窗口显示无法加载页面,但控制台没有显示任何错误。我尝试改变

“main”:“http://localhost:8080”到“main”:“http://localhost:3000

这是应用程序通常的运行方式,但它也不起作用。

这可能吗? 我错过了什么?

提前致谢

【问题讨论】:

    标签: node.js node-webkit express-generator


    【解决方案1】:

    这可能有点晚了,但无论如何。 以下是来源:https://github.com/nwjs/nw.js/wiki/NW.js-use-express-and-similar-web-frameworks

    node-main 应该有文件路径,用于设置服务器。在这种情况下,我假设它位于 bin 目录中并命名为 www。因此,package.json 应该是这样的:

    {
     ...
     "node-main": "./bin/www",
     "main": "http://localhost:3000",
     ...
    }
    

    还要检查端口号是否为 3000 或其他。

    【讨论】:

      猜你喜欢
      • 2014-03-16
      • 1970-01-01
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-26
      相关资源
      最近更新 更多