无法使用node.js运行appjs示例应用程序

我想运行一个示例项目使用appjs这是在这里https://github.com/appjs/appjs/tree/master/examples目前。 我在Windows(64位机器)上使用最新版本的node.js(v4.1.0)

当我尝试使用命令提示符下面的命令运行示例

节点 – 和谐index.js

我得到一个错误如下,

Error: AppJS requires Node is run with the --harmony command line flag at Object.<anonymous> (F:\programs\appjs_examples\node_modules\appjs\lib\ind ex.js:2:9) at Module._compile (module.js:434:26) at Object.Module._extensions..js (module.js:452:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (F:\programs\appjs_examples\octosocial\index.js:1:73) at Module._compile (module.js:434:26) at Object.Module._extensions..js (module.js:452:10) 

我试图寻找这个问题,但我找不到解决scheme。 任何人都可以告诉我如何使用node.js与和谐旗帜?

更新我的index.js看起来像这样

 var app = require('appjs'), github = new (require('github'))({ version: '3.0.0' }), KEY_F12 = process.platform === 'darwin' ? 63247 : 123; app.serveFilesFrom(__dirname + '/assets'); var window = app.createWindow({ width: 460, height: 640, resizable: false, disableSecurity: true, icons: __dirname + '/assets/icons' }); window.on('create', function(){ window.frame.show(); window.frame.center(); }); window.on('ready', function(){ var $ = window.$, $username = $('input[name=username]'), $password = $('input[name=password]'), $info = $('#info-login'), $label = $info.find('span'), $buttons = $('input, button'); $(window).on('keydown', function(e){ if (e.keyCode === KEY_F12) { window.frame.openDevTools(); } }); $username.focus(); $('#login-form').submit(function(e){ e.preventDefault(); $info.removeClass('error').addClass('success'); $label.text('Logging in...'); $buttons.attr('disabled', true); github.authenticate({ type: 'basic', username: $username.val(), password: $password.val() }); github.user.get({}, function(err, result) { if (err) { $info.removeClass('success').addClass('error'); $label.text('Login Failed. Try Again.'); $buttons.removeAttr('disabled'); } else { loggedIn(result); } }); }); function loggedIn(result){ $label.text('Logged in!'); $('#user-avatar').append('<img src="'+result.avatar_url+'" width="64" height="64">'); $('#user-name').text(result.name); $('#login-section').hide(); $('#profile-section').show(); ['Followers', 'Following'].forEach(function(type){ github.user['get'+type]({ user: result.login }, populate.bind(null, type.toLowerCase())); }); } 

现在Node.js的v0.12我得到下面的错误

  F:\softwares\Node.js_v0.12\node_modules\appjs\lib\index.js:2 throw new Error ('AppJS requires Node is run with the --harmony command line Error: AppJS requires Node is run with the --harmony command line flag at Object.<anonymous> (F:\softwares\Node.js_v0.12\node_modules\appjs\lib\ind ex.js:2:9) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (F:\softwares\Node.js_v0.12\index.js:1:73) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) 

刚刚使用节点v0.12.7和v4.0.0在本地testing了您的代码。 看起来像node_modules/appjs/lib/index.js检查确保无论如何启用代理。

--harmony标志默认不启用代理。 不过你可以使用--harmony_proxies

为了帮助您了解正在发生的事情:

  1. 在您的terminal打开node ,然后键入Proxy 。 你会得到'代理没有定义'。

  2. 现在,在terminal中打开node --harmony一致。 你会得到相同的输出。

  3. 现在,用node --harmony-proxies 。 巴姆,你得到一个空的物体。

你应该可以用v4.xx来运行这个,但是你仍然需要代理标志和谐。

当与第四版的node.js和io.js合并时,他们发布了一个ES6特性页面,如果您使用的是4.xx https://nodejs.org/en/docs/es6/

https://github.com/appjs/appjs被弃用btw,但是一旦你通过模块的functiontesting,将需要32&#x4F4D;;)

编辑:

要正确运行您的应用程序使用以下内容:

node --harmony-proxies index.js

以下是显示上述第3步的预期输出的截图。 在这里输入图像描述