繁体   English   中英

USB模块发生故障的节点Webkit应用程序

[英]Node webkit application with USB module failing

我正在使用node-webkit编写桌面应用程序。 我已经使用节点USB模块编写了脚本,如果我使用节点运行该脚本,它将可以正常工作。 它列出了所有USB设备,连接,读取,写入。 现在,我想使用node-webkit应用程序实现相同的功能,其中HTML有一个按钮,我们必须在上面执行这些操作。 现在,为此,我们需要配置节点模块。 我已经将该模块添加到我的项目中,然后按照提到的步骤进行处理

package.json

{
  "name": "node-webkit-angular-bootstrap-starter",
  "version": "0.0.1",
  "description": "Starter destkop app using node-webkit, html5, angular, and bootstrap",
  "main": "app/index.html",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT",
  "window": {
    "title": "node-webkit-angular-bootstrap-starter",    
    "toolbar": true,
    "frame": true,
    "width": 1024,
    "height": 768,
    "position": "center"
  },
  "dependencies"  : {
    "node-pre-gyp": "0.6.9"
  },
  "bundledDependencies":["node-pre-gyp"],
  "devDependencies": {
    "aws-sdk": "~2.0.0-rc.15"
  },
  "scripts": {
    "install": "node-pre-gyp install --fallback-to-build"
  },
  "binary": {
    "module_name": "usb",
    "module_path": "./app/lib/binding/",
    "host": "https://github.com/camsoupa/node-usb"
  }
}

Home.js

(function () {    'use strict';  app.controller('homeController', function ($scope) {alert("Heelooooo");


var gui = require('nw.gui');
var os = require('os'); 

$scope.settings = [];
$scope.usb = require('usb');   });})();

使用nw运行应用程序时出现以下错误

"%1 is not a valid Win32 application.
↵D:\Projects\…er\node_modules\usb\src\binding\usb_bindings.node"}

有人可以帮帮我吗?

我通过编译正确的体系结构解决了这个问题。 在我的环境中,节点是32位,而nw是64位。 将目录更改为usb模块,以下两个命令通过创建64位版本的本机绑定解决了该问题:

nw-gyp configure --target=0.12.3 --module_name=usb_bindings --module_path=..\src\binding\ --target_arch=x64

nw-gyp build --target=0.12.3 --module_name=usb_bindings --module_path=..\src\binding\ --target_arch=x64

module_namemodule_path变量是必需的,因为无论出于何种原因, nw-gyp都不从binding.gyp文件获取其值。

可能导致您描述的错误的nw.exe件事是将nw.exe重命名为其他内容。 只要将其命名为nw.exe ,这些符号就可以正确绑定。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM