Im trying to build desktop app using Electron JS + React JS + Vite by using command (npm i electron-vite@latest)
It works fine, now there is a need to communicate to serialport, so installed (npm i serialport)node js seripaport , when i try to import serial port library and start launch application using (npm run dev)
package.json
“scripts”: {
“dev”: “vite”,
“build”: “tsc && vite build && electron-builder”,
“lint”: “eslint . –ext ts,tsx –report-unused-disable-directives –max-warnings 0”,
“preview”: “vite preview”
},
App threw an error during load
ReferenceError: __dirname is not defined in ES module scope
An i try to build a app without vite, it works fine with serialport
Is there any idea why it not works with Vite and Works without vite
Maithreyan _M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.