laux98 opened a new issue, #261:
URL: https://github.com/apache/cordova-electron/issues/261

   # Bug Report
   
   ## Problem
   
   Hello, my problem is when I include the library SerialPort in my 
cordova-electron projet, build crashe on windows 10 , window 11 and Ubuntu 
22.04.
   
   ### What is expected to happen?
   Build launch and I can use serial port.
   
   ### What does actually happen?
   Build don't launch and error is displayed.
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   I am trying to use the serial port library on cordova-electron.
   When i use 
   ```cordova run electron --nobuild ```, this work perfectly and the 
application is launch.
   When i want to do the build, I use 
   ```cordova build android```and there are no errors. 
   But when I launch the build , this error is displayed :
   
   ```
   A JavaScript error occurred in the main process
   Uncaught Exception:
   Error: Cannot find module 'serialport'
   Require stack:
   - 
/pathToMyProject/cordova/platforms/electron/build/linux-unpacked/resources/app.asar/cdv-electron-main.js
   - 
       at Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
       at Function.n._resolveFilename (electron/js2c/browser_init.js:245:1128)
       at Module._load (internal/modules/cjs/loader.js:737:27)
       at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
       at Module.require (internal/modules/cjs/loader.js:964:19)
       at require (internal/modules/cjs/helpers.js:88:18)
       at Object.<anonymous> 
(/pathToMyProject/cordova/platforms/electron/build/linux-unpacked/resources/app.asar/cdv-electron-main.js:27:24)
       at Module._compile (internal/modules/cjs/loader.js:1083:30)
       at Object.Module._extensions..js (internal/modules/cjs/loader.js:1113:10)
       at Module.load (internal/modules/cjs/loader.js:940:32)
   
   ```
   
   The line "cdv-electron-main.js:27:24" is 
   ```
   const { SerialPort } = require("serialport");
   ```
   
   I have the same issue in Windows 10, Windows 11 and Ubuntu22.04.
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   In the file 
"pathToMyProjetct/cordova/platforms/electron/platform_www/cdv-electron-main.js",
 I include the line 
   ```const { SerialPort } = require("serialport");```
   to use the library. 
   
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   Ubuntu 22.04 
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   serialport : 12.0.0 
   Ubuntu : 22.04 
   cordova-electron : 3.1.0
   cordova : 12.0.0
   react:18.2.0
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to