If you go to https://github.com/maximegris/angular-electron you can see how to use native libraries at the bottom the page.

In electron.service.ts add the import:

import * as SerialPort from 'serialport';

Then inside the ElectronService class add:

serialPort: typeof SerialPort;

Then inside the constructor add to the if statement the following:

if(this.isElectron()){
   [...]
   this.serialPort = window.require('serialport');
}

Back in the home.components.ts file add the import

import {ElectronService} from '../../providers/electron.service';

Inject the service into the constructor:

constructor(private electron:ElectronService){...}

Finally, in the ngOnInit() function you can use the serial port like so:

this.electron.serialPort.list().then((ports:any)=>{
   [...]
}).catch((err:any)=>{
   [...]
});
Answer from Al55 on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 73055385 › how-to-read-data-from-serial-port-by-angular-web-application
How to read data from serial port by Angular Web Application? - Stack Overflow
July 20, 2022 - I'm not quite sure what you're trying to do. But maybe using a NodeJs script you can access the data from this port and then send it to angular. Can i monitor an existing serial port communication with node.js?
Discussions

Serialport Issues
Now I would like to add serialport to my Angular-Electron app. So I installed npm install serialport --save npm install @types/serialport --save · I placed "import * as SerialPort from 'serialport'" in "home.components.ts" After invoking the code below nothing but errors: `//List serial ports ... More on github.com
🌐 github.com
11
October 31, 2019
Is it possible to use node-serialport?
Hi, I've been trying to implement an Angular 6 + Electron app that uses node-serialport (https://www.npmjs.com/package/serialport), but so far I had no luck. What I've tried: npm i serialpo... More on github.com
🌐 github.com
1
August 22, 2018
node.js - using serialPort library with Angular - Stack Overflow
I use Node Version 14.17.6 and I would like to read one of the serial ports of the computer through Angular. I'm not sure if it can be done directly from Angular and I would like to know if maybe i... More on stackoverflow.com
🌐 stackoverflow.com
angular - Electron + Angular7 How to use serialport.list() in a Component - Stack Overflow
Thanks to another member on stackoverflow I was able to use SerialPort in an Electron App. Now on the next issue. I have a component in Angular that I would like to have a dropdown to select a More on stackoverflow.com
🌐 stackoverflow.com
December 17, 2018
🌐
GitHub
github.com › serialport › node-serialport › issues › 1975
Angular + Electron + serialport | Issues with Typescript · Issue #1975 · serialport/node-serialport
October 31, 2019 - Expanded further with an Angular app -> Can not get it working :-( What happens? As soon as i try to interact with serialport by typescript the program crashes · What should have happened? A Typescript Variation would be nice · i installed also "@types/serialport": "^7.0.4", // none of the following is working const SerialPort = require('serialport'); import * as SerialPort from 'serialport'; ... async readAvailablePorts() { const ports = await SerialPort.list(); console.log('Available SerialPorts: ', ports); } Angular: 8.2.13 ·
Author   serialport
🌐
Google Groups
groups.google.com › g › angular › c › bJDloHeEGHM
read data from serial port using angular2
August 14, 2019 - To view this discussion on the web visit https://groups.google.com/d/msgid/angular/07b803ec-7f84-4472-a647-b57ff0c28d13@googlegroups.com. ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... Yes, that is a constraint Google did put in Chrome. Clearly documented in that repo. There is also web-serial in the pipeline.
🌐
The Mail Archive
mail-archive.com › angular@googlegroups.com › msg28816.html
[AngularJS] read data from serial port using angular2
August 14, 2019 - and import { SerialPort } from 'serialport' in component.ts serialPort: typeof SerialPort; now we got undefined from serialPort. and got the Can't resolve 'child_process' node_modules\@serialport\bindings\lib <https://stackoverflow.com/questions/57476591/cant-resolve-child-process-node-modules-serialport-bindings-lib-in-angular2> error for get port.
🌐
GitHub
github.com › maximegris › angular-electron › issues › 103
Serialport Issues · Issue #103 · maximegris/angular-electron
October 31, 2019 - //open com port 4 this.com = new SerialPort('COM4', {baudRate : 19200}, (err: Error) => { if (err) { console.log('Open Error: ', err.message); } });`
Author   maximegris
🌐
GitHub
github.com › angular-guru › electron-builder › issues › 1
Is it possible to use node-serialport? · Issue #1 · angular-guru/electron-builder
August 22, 2018 - I've been trying to implement an Angular 6 + Electron app that uses node-serialport (https://www.npmjs.com/package/serialport), but so far I had no luck. ... import * as SerialPort from 'serialport' constructor(){ SerialPort.list().then( ports => console.log(ports)).catch(err => console.log(err)); }
Author   angular-guru
Find elsewhere
🌐
YouTube
youtube.com › sung hah hwang
Serialportron app demo (Angular + Serialport + Electron) - YouTube
Demo video of Serialportron example app Angular + Serialport + Electron + Bootstrap GitHub link: https://github.com/Sunghah/serialportron
Published   July 18, 2018
Views   1K
🌐
GitHub
github.com › archocron › ngx-serial-example
GitHub - archocron/ngx-serial-example: Angular application using the npm package 'ngx-serial' connected with an ARDUINO
June 21, 2021 - if(!this.port){ this.serial.connect((port:any)=>{ this.port = port; }); if(this.port) this.serial.sendData("L1\n"); if(this.port) this.serial.close((port:any)=>{ this.port = port; }); <div *ngIf="this.port"> <span class = "greendot"></span> <span>Connected</span> </div> <div *ngIf="!this.port"> <span class = "reddot"></span> <span>Disconnected</span> </div> To check an example application made on Angular click here The Arduino Code is located on src/assets/ngx-serial-example.ino ·
Author   archocron
🌐
Hackster.io
hackster.io › user466315 › working-with-arduino-node-js-and-angular-11eab4
Working with Arduino, Node.js and Angular - Hackster.io
November 10, 2018 - Through the API, our application developed in Angular will read in intervals the data of the bank and display them. Let's work on the idea of ​​a temperature gauge. ... First let's read the sensor data through the analog port is to write them on the serial port.
🌐
Stack Overflow
stackoverflow.com › questions › 76619579 › using-serialport-library-with-angular
node.js - using serialPort library with Angular - Stack Overflow
ERROR in node_modules/serialport/dist/serialport.d.ts:4:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class. This likely means that the library (serialport) which declares SerialPort has not been processed correctly by ngcc, or is not compatible with Angular Ivy.
🌐
GitHub
github.com › archocron › ngx-serial
GitHub - archocron/ngx-serial: NgxSerial eases the use of the Serial Web API in Angular.
June 21, 2021 - if(!this.port){ this.serial.connect((port:any)=>{ this.port = port; }); if(this.port) this.serial.sendData("L1\n"); if(this.port) this.serial.close((port:any)=>{ this.port = port; }); <div *ngIf="this.port"> <span class = "greendot"></span> <span>Connected</span> </div> <div *ngIf="!this.port"> <span class = "reddot"></span> <span>Disconnected</span> </div> To check an example application made on Angular click here The Arduino Code is located on src/assets/ngx-serial-example.ino ·
Starred by 5 users
Forked by 9 users
Languages   TypeScript 81.7% | JavaScript 18.3% | TypeScript 81.7% | JavaScript 18.3%
🌐
Arduinoslovakia
arduinoslovakia.eu › blog
Arduino Slovakia - Angular javascript app and Arduino
December 25, 2017 - This code provides communication via sockets. When connected, the AngularJS application opens the selected serial port and reads the individual rows sent by Arduino. These rows are sent through the socket to the AngularJS application.
🌐
Stack Overflow
stackoverflow.com › questions › 77940753 › serialport-angular-send-instructions-to-serialport-after-reading-its-message
electron - SerialPort/Angular send instructions to serialPort after reading its message - Stack Overflow
I used 'ngx-serial' for my angular project and I want to send some data to the serialPort after reading the results it sends. I get those errors: ... dataHandler(data: string) { console.log("From serial port -> " + data); this.myResult = data.replace(/\r/g, '');; console.log('myResult: ', this.myResult); this.readMyStream(this.myResult); } readMyStream(data: string) { setTimeout(() => { const words = data.split(' '); if (words[0] === '**' && words[3] === '****') { this.serial.sendData(`*** ** ****\n`); console.log('hhihih'); // Alternatively, display message in template } }, 9000) }
🌐
npm
npmjs.com › package › browser-serialport
browser-serialport - npm
December 14, 2016 - This library only works in a Chrome Packaged App as this is the only way to get access to the serial ports API in the browser. Incidentally, since NW.js (a.k.a.
      » npm install browser-serialport
    
Published   Dec 14, 2016
Version   2.1.0
🌐
C# Corner
c-sharpcorner.com › forums › how-to-read-serial-port-data-by-anguler-web-application
How to read serial port data by Angular Web application ?
I have a simple Arduino device that created for reading RFID. It returns UID of the RFID tag to serial port of client PC.I need to read that value returned by Arduino device using Angular web appl...
🌐
npm
npmjs.com › package › serialport
serialport - npm
Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords.
      » npm install serialport
    
Published   Dec 24, 2024
Version   13.0.0
🌐
Angular Questions
angularquestions.com › tag › serial-port
serial-port – Angular Questions
I’m trying to implement data reading through a serial port in my Angular project (using electron), but after installing the serial-port package I’m getting errors of ‘Module not found’. The followings are my reference for the project Angular(5)-Electron Serialport Support https://www.npmjs.com/package/serialport The Error I’m getting electron service import { Injectable } from ‘@angular/core’; import * […]