Node-Webkit上的Meteor排行榜应用 [英] Meteor leaderboard app on node-webkit

查看:75
本文介绍了Node-Webkit上的Meteor排行榜应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使流星排行榜应用程序在Node-Webkit上运行. 我已经对其进行了去气化处理并将其压缩为.nw文件,但是当我将其放入时,会出现错误:

无效的软件包软件包中没有'package.json',请 确保"package.json"位于软件包的根目录中.

我在各种线程上都读过,但还不清楚. 似乎需要重新配置经过风化处理的应用程序.还需要弄清楚如何在本地[DDP]上运行服务器.

P.S.我正在使用排行榜流星应用程序中的经过去甲化处理的文件,以便能够在node-webkit中运行它.

我要在这里找出的确切内容是:

  1. 如何运行/初始化本地服务器(已变美化)并设置端口.

  2. 如何为mongodb等的经过过气象处理的应用设置环境变量.

  3. 将用作

主要":?,
节点远程":?

用于node-webkit package.json文件.

有人可以说明一下吗,如果可能的话,将不胜感激.

非常感谢.

普兰尼:)

更新:

稍作修改后,我添加了"main":"index.html",并将index.html文件添加到了经过去甲化处理的应用程序的根目录中.该文件仅将main.js文件加载到浏览器中,此处:

<!DOCTYPE html>
<html>
  <head>
    <title>Leaderboards</title>
  </head>
  <body>
  </body>
  <script src="main.js" type="text/javascript"></script>
</html>

现在我收到此错误:

未捕获的ReferenceError:__dirname未定义",来源: 文件:///Users/Praney/projects/webkit/nw-sample-apps/leaderboards/main.js(2)

main.js

process.argv.splice(2, 0, 'program.json');
process.chdir(require('path').join(__dirname, 'programs', 'server'));
require('./programs/server/boot.js');

解决方案

这不是应该使用去氨化剂的方式.

您将使用已部署服务器上的输出捆绑包作为流星应用程序运行,而不是将其放在现有的流星应用程序中.

从中获得的package.json与流星npm使用的package.json稍有不同.

完成流星应用程序后,您将使用demeteorizer创建一个可以在您的服务器上运行的简单捆绑包.如果您上传了它并取消了它的发布:

  1. 您可以通过绑定到软件包中并运行npm install
  2. 来安装npm模块.
  3. 您可以按照文档中的说明正常运行应用程序.

Demeteorizer的全部目的是对您的应用程序进行修饰,由于所有npm模块都已经在工作,因此您不需要在所使用的平台上进行修饰.它解决的问题通常是跨体系结构,例如,如果您在OS X上创建应用程序,并且使用二进制npm模块,而服务器使用Ubuntu(不是os x)

我想node-webkit也可以做到这一点,您需要为此使用demeteorize的根目录(与应用程序分离).您会看到其中已经有一个package.json,也许您将其设置为要使用的根目录是流星应用程序的根目录,而不是经过去甲化处理的应用程序的无损输出?

I am trying to get the meteor leaderboard app to run on Node-Webkit. I have demeteorized it and compressed it to a .nw file but when I drop it in. I get errors:

Invalid Package There is no 'package.json' in the package, please make sure the 'package.json' is in the root of the package.

I have read on various thread but nothing clear yet. It seems like the demeteorized app needs to be restructured. Also need to figure out how to run the server [Locally/DDP].

Edited:

P.S. I am using the demeteorized files from the leaderboard meteor app to be able to run it in node-webkit.

What exactly I am trying to figure out here is :

  1. how to run/init the local node(demeteorized) server and set the port.

  2. How to set environment variables for the demeteorized app for mongodb etc.

  3. What would be used as the

"main": ?,
"node-remote": ?

for the node-webkit package.json file.

Can someone please shed some light and if possible an example will be highly appreciated.

Thanks in advanced.

Praney :)

UPDATE:

After tinkering a bit, I added the "main": "index.html" and added index.html file to the root of the demeteorized app. This file just loads the main.js file in the browser, here:

<!DOCTYPE html>
<html>
  <head>
    <title>Leaderboards</title>
  </head>
  <body>
  </body>
  <script src="main.js" type="text/javascript"></script>
</html>

Now I am getting this error:

"Uncaught ReferenceError: __dirname is not defined", source: file:///Users/Praney/projects/webkit/nw-sample-apps/leaderboards/main.js(2)

main.js

process.argv.splice(2, 0, 'program.json');
process.chdir(require('path').join(__dirname, 'programs', 'server'));
require('./programs/server/boot.js');

解决方案

This isn't how demeteorizer is meant to be used.. exactly/kind of.

You would use the output bundle on your deployed server to run as your meteor app, not put it in an existing meteor app.

The package.json that you get from it is slightly different to the one that meteor-npm would use.

When you've finished your meteor app you would use demeteorizer to create an easy bundle that can run on your server. If you uploaded it and untarred it:

  1. You would install the npm modules by cding into the bundle and running npm install
  2. You can run the app as normal as described in the docs.

The whole purpose of demeteorizer is to nodify your app, you wouldn't need to this on the platform you made it since all the npm modules would already be working. The problem it solves is usually with cross-archs, e.g if you made your app on OS X and it uses binary npm modules and the server uses Ubuntu (not os x)

I suppose node-webkit could also do it, you would need to use the root directory of demeteorize for this (seperate from your app). You can see there's a package.json already in it, perhaps the root directory you set it to use is that of your meteor app and not the untarred output of the demeteorized app?

这篇关于Node-Webkit上的Meteor排行榜应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆