-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use serialport in electron, I get error about "indexof" #1789
Comments
could anyone help me to take a look? |
I have seen this error too. The root cause may be related to this issue kusti8/proton-native#196 .. I wonder if porting the native library to https://github.com/charto/nbind would resolve issues like these. |
N-Api will help with these issues, someone is experimenting with it right now, come this April when we drop node 6 support we’ll be able to switch. As I understand it Nbind won’t work because we have to be use c++ system calls |
Also I don’t think the two of you have similar issues. |
I'm having exactly the same issue. The code runs perfectly in the development environment in electron application. But throws the same error in production. I tested the latest version of serialport@7.1.4 with latest major releases of electron 2.x.x, 3.x.x and 4.x.x. Throws the same error all the time. @wiener0zyj were you able to find a solution to this? |
Ok. I think i found out what was causing the problem for me. I'm using webpack to bundle certain modules, was relying on |
@Nishkalkashyap thanks very much! I have solved the problem, only electron 1.8.8 could support serialport.io. all the other versions such as 2.xx 3.xx and 4.xx could not work at all. |
Why?
|
Well. As I said earlier, serialport sure does works for me with electron. At least the version v4.0.5 of electron that I use. To reiterate, my only problem was that I was bundling serialport with webpack, which fails. As soon as I add serialport as external module in webpack, everything works fine. |
I had the same issue with serialport in my Electron app when I tried to update from serialport 6.2.2 to 7.1.4. Reverting back to 6.2.2 solved my problem. |
I also found myself dealing with this. I'll leave the webpack configuration that worked for me for other users for future reference:
The serialport section in the output bundle for this configuration would look like this:
This means that when the app requires serialport it will end up resolving to the one located in the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week no further activity occurs. Feel free continue the discussion or ask for a |
I was using vue-cli-plugin-electron-builder and had the same problem, the solution in my case was to mark serialport as external for the builder
See here: electron-userland/electron-builder#3696 |
My enviroment:
If you are using Eletron with Vue.js you need to rebuild the serialport module doing something like this:
after this, you can add in your package.json > section "scripts", another line saying:
You can rebuild the module with terminal command
Now the serialport module should be imported and will work as expected. Goog luck! |
Summary of Problem
(Please answer all 3)
I'm tring to use serialport in electron with react, after i webpack my codes and run npm start, I get this:
### Uncaught TypeError: Cannot read property 'indexOf' of undefined
please help take a look at it.
error happen when running:
I think it should works well
Code to Reproduce the Issue
Versions, Operating System and Hardware
SerialPort@?
Node.js v?
v10.15.0
Windows? Linux? Mac?
Win10
Hardware and chipset? (Prolific/FTDI/Other)
The text was updated successfully, but these errors were encountered: