Issues with Serialport (Angular-Electron)


#1

Hi,

in the past I wrote some applications in Nodejs+Typescript with SerialPort native module to communicate over RS232 with diffenrent hardware systems.

Now I would like to add serialport to my Angular-Electron app.
So I installed
npm install serialport --save
npm install --save

I placed “import * as SerialPort from ‘serialport’” in "home.components.ts"
After invoking the code below nothing but errors:

`//List serial ports
SerialPort.list( (err:Error, ports:any[]) => {
ports.forEach((port:any) => {
console.log(‘Com Name ’ +port.comName +
’ | Manufac ’ +port.manufacturer +
’ | Vendor ID '+ port.vendorId );
});
});

//open com port 4
this.com = new SerialPort(‘COM4’, {baudRate : 19200}, (err: Error) => {
if (err) {
console.log('Open Error: ', err.message);
}
});`

Browser DevTool Log:
getRoot @ vendor.bundle.js:87243
bindings @ vendor.bundle.js:87139
./node_modules/serialport/lib/bindings/linux.js @ vendor.bundle.js:109113
webpack_require @ inline.bundle.js:55
(anonymous) @ vendor.bundle.js:108666
./node_modules/serialport/lib/bindings/auto-detect.js @ vendor.bundle.js:108669
webpack_require @ inline.bundle.js:55
./node_modules/serialport/lib/index.js @ vendor.bundle.js:109589
webpack_require @ inline.bundle.js:55
(anonymous) @ main.bundle.js:268
./src/app/components/home/home.component.ts @ main.bundle.js:348
webpack_require @ inline.bundle.js:55
./src/app/app-routing.module.ts @ main.bundle.js:38
webpack_require @ inline.bundle.js:55
./src/app/app.module.ts @ main.bundle.js:164
webpack_require @ inline.bundle.js:55
./src/main.ts @ main.bundle.js:418
webpack_require @ inline.bundle.js:55
0 @ main.bundle.js:507
webpack_require @ inline.bundle.js:55
webpackJsonpCallback @ inline.bundle.js:26
(anonymous) @ main.bundle.js:1

Any hint how to get it running? I need SerialPort support in my Angluar-Electron application.
In Python, C, Java that’s no problem.

Any help is appreciated
JP