我正在使用socket.io& amp; arduino的serialport依赖。 我对节点
有以下的sever.jsvar express = require('express');
var app = express();
var http = require('http');
var url = require('url');
var SerialPort = require('serialport').SerialPort;
var server = http.createServer(app);
var io = require('socket.io').listen(server); //pass a http.Server instance
// "process.env.PORT" to set port by Heroku
var port = process.env.PORT || 3000;
server.listen(port, function(){
console.log('listening on:' + port);
});
// Serial Port
var serialPort = new SerialPort("/dev/cu.usbserial-XXXXXXXX", {
baudrate: 115200
});
...... Some code here ..............
serialPort.on('close', function(err) {
console.log('port closed');
});
//serialport open
serialPort.open(function () {
console.log('port open');
});
我还在package.json中为serverport
设置了依赖。
此代码在我的localhost服务器上正常工作但是当我尝试在Heroku上运行此代码时,我收到以下错误:
events.js:85
throw er; // Unhandled 'error' event
Error: Cannot open /dev/cu.usbserial-XXXXXXXX
at Error (native)
为什么这样? Heroku-serverport有什么特殊要求吗?