使用NodeJs serialPort - 错误:%1不是有效的Win32应用程序

时间:2016-08-16 18:34:30

标签: node.js bash npm serial-port electron

我正在尝试让serialport(https://www.npmjs.com/package/serialport)在Windows上运行,这样我就可以将命令发送到我的串口,从而打开/关闭锁。

serialport是通过bash安装的。

npm install serialport --save-dev

以下是错误

C:\Users\[...]\electron-with-express\express-app\node_modules\bindings\bindings.js:83

Error: %1 is not a valid Win32 application.

以下是页面

var express = require('express');
var router = express.Router();
var SerialPort = require('serialport');

// check which port is available
//var sp = require('../');


/* GET home page */
router.get('/', function(request, response){

    //sp.list(function(err, ports) {
 // console.log(ports);
//});

 SerialPort.list(function (err, ports) {
  ports.forEach(function(port) {
    console.log(port.comName);
    console.log(port.pnpId);
    console.log(port.manufacturer);
  });
});
});

// Important
module.exports = router;

NodeJs应用程序正在通过Electron运行

1 个答案:

答案 0 :(得分:1)

必须重建serialport等原生节点模块以定位您正在使用的特定Electron版本,为此,请按照http://electron.atom.io/docs/tutorial/using-native-node-modules/

中记录的步骤进行操作

还有一个涵盖主题的open issue,所以如果你至少被卡住了this comment