GitHub user erisu added a comment to the discussion: I cant use in Cordova-Electron require
`require` is not available in the front-end (web) context of a Cordova application. To use modules like `SerialPort`, you need to create a **Cordova plugin** that includes the `SerialPort` module in its native (Electron) implementation. The plugin should expose APIs that the front-end can call through the Cordova JS bridge. The **native layer** of the plugin would internally handle requiring and interacting with the `SerialPort` module. Communication flow: **Application Logic** ↔ **Cordova Plugin (Front-end Layer)** ↔ **Cordova JS Bridge** ↔ **Cordova Plugin (Native Layer)** Cordova-Electron uses [**Context Isolation**](https://www.electronjs.org/docs/latest/tutorial/context-isolation)), which affects how scripts interact with Electron internals: > Context Isolation is a feature that ensures both your preload scripts and > Electron's internal logic run in a separate context from the website loaded > in a `webContents`. This improves security by preventing the website from > accessing Electron internals or the powerful APIs exposed by preload scripts. For a reference implementation, the [**Cordova Device Plugin**](https://github.com/apache/cordova-plugin-device) provides a good example of how to structure a plugin that supports Electron. GitHub link: https://github.com/apache/cordova/discussions/547#discussioncomment-13515368 ---- This is an automatically sent email for issues@cordova.apache.org. To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org