I tried to do serial port to listen my COMports with electron-vue.js. When I try to code this below.
const SerialPort = require("serialport");
const Readline = SerialPort.parsers.Readline;
const port = new SerialPort("COM3", {
baudRate: 9600,
});
const parser = new Readline();
port.pipe(parser);
//Read Data
parser.on("data", (line) => {
console.log(line);
});
//Send Data
parser.write("Sended Data !");
I got this below error in console.
TypeError: Cannot read property 'modules' of undefined at Object.eval (bindings.js?dfc1:29) at eval (bindings.js:223) at Object../node_modules/bindings/bindings.js (0.js:231) at webpack_require (app.js:854) at fn (app.js:151) at eval (linux.js?88eb:2) at Object../node_modules/@serialport/bindings/lib/linux.js (0.js:65) at webpack_require (app.js:854) at fn (app.js:151) at Object.eval (index.js?c888:14)
How can I solve this problem ?
By the way, When I try to run this code in node.js, it runs. But when I try to run this code in Vue.js, it did not run.
Thanks