node-serialport causes issues with binding module

Created on 8 Aug 2019  Â·  10Comments  Â·  Source: serialport/node-serialport

Summary of Problem

I am trying to implement the node-serialport module into a react application. However, when I add const SerialPort = require('serialport'); My application crashes saying TypeError: exist is not a function, and points to /node_modules/bindings/bindings.js

i installed serialport using npm install serialport
and I have also tried npm install serialport --build-to-source

What can I do to fix this issue?

Thank you

Code to Reproduce the Issue

const SerialPort = require('serialport')

image

Versions, Operating System and Hardware

Most helpful comment

@HipsterBrown I created a new project and migrated the code over and installed serialport, electron and electron rebuild again and it is working now.

Thank you everyone for your help

All 10 comments

Are you running in a browser?

On Thu, Aug 8, 2019 at 9:23 AM Rushinko notifications@github.com wrote:

Summary of Problem

(Please answer all 3)

I am trying to implement the node-serialport module into a react
application. However, when I add const SerialPort = require('serialport');
My application crashes saying TypeError: exist is not a function, and
points to /node_modules/bindings/bindings.js

i installed serialport using npm install serialport
and I have also tried npm install serialport --build-to-source

What can I do to fix this issue?

Thank you
Code to Reproduce the Issue

const SerialPort = require('serialport')

[image: image]
https://user-images.githubusercontent.com/20117482/62706741-222fe600-b9be-11e9-9f88-6c36aff58c2b.png
Versions, Operating System and Hardware

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/serialport/node-serialport/issues/1907?email_source=notifications&email_token=AAAGK3WVM73WLDW4CQV2LZTQDQM4VA5CNFSM4IKKKTKKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HEE3NPA,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAGK3UGCSMOZOTM7ISIVOLQDQM4VANCNFSM4IKKKTKA
.

>


Francis Gulotta
[email protected]

Are you running in a browser?
On Thu, Aug 8, 2019 at 9:23 AM Rushinko @.> wrote: Summary of Problem (Please answer all 3) I am trying to implement the node-serialport module into a react application. However, when I add const SerialPort = require('serialport'); My application crashes saying TypeError: exist is not a function, and points to /node_modules/bindings/bindings.js i installed serialport using npm install serialport and I have also tried npm install serialport --build-to-source What can I do to fix this issue? Thank you Code to Reproduce the Issue const SerialPort = require('serialport') [image: image] https://user-images.githubusercontent.com/20117482/62706741-222fe600-b9be-11e9-9f88-6c36aff58c2b.png Versions, Operating System and Hardware - *@.* - Node.js v12.8.0 - Windows 10 (x64) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1907?email_source=notifications&email_token=AAAGK3WVM73WLDW4CQV2LZTQDQM4VA5CNFSM4IKKKTKKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HEE3NPA>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAGK3UGCSMOZOTM7ISIVOLQDQM4VANCNFSM4IKKKTKA .
-- --- Francis Gulotta [email protected]

Yes I am.

Browsers don’t have serialport access. There’s a chrome experimental
feature for a new serialport spec but it’s not shipping yet and probably
won’t for a long while. Most people use node or electron.

On Thu, Aug 8, 2019 at 11:04 AM Rushinko notifications@github.com wrote:

Are you running in a browser?
On Thu, Aug 8, 2019 at 9:23 AM Rushinko @.> wrote: Summary of Problem
(Please answer all 3) I am trying to implement the node-serialport module
into a react application. However, when I add const SerialPort =
require('serialport'); My application crashes saying TypeError: exist is
not a function, and points to /node_modules/bindings/bindings.js i
installed serialport using npm install serialport and I have also tried npm
install serialport --build-to-source What can I do to fix this issue? Thank
you Code to Reproduce the Issue const SerialPort = require('serialport')
[image: image]
https://user-images.githubusercontent.com/20117482/62706741-222fe600-b9be-11e9-9f88-6c36aff58c2b.png
https://user-images.githubusercontent.com/20117482/62706741-222fe600-b9be-11e9-9f88-6c36aff58c2b.png
Versions, Operating System and Hardware - @.
- Node.js v12.8.0 - Windows
10 (x64) — You are receiving this because you are subscribed to this
thread. Reply to this email directly, view it on GitHub <#1907
https://github.com/serialport/node-serialport/issues/1907?email_source=notifications&email_token=AAAGK3WVM73WLDW4CQV2LZTQDQM4VA5CNFSM4IKKKTKKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HEE3NPA>,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAGK3UGCSMOZOTM7ISIVOLQDQM4VANCNFSM4IKKKTKA
.
-- --- Francis Gulotta [email protected]

Yes I am.

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/serialport/node-serialport/issues/1907?email_source=notifications&email_token=AAAGK3WMHDBXSFXHF7YB3KLQDQYWZA5CNFSM4IKKKTKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD335GHI#issuecomment-519557917,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAGK3RFZU6TQRA2TNWRMSTQDQYWZANCNFSM4IKKKTKA
.

>


Francis Gulotta
[email protected]

I apologize I misinterpreted the first question I think. I am using node with react so it’s rendering in chrome, however I’m still using node. Would that still not work? I also have separate issues attempting it with electron but I think that’s an electron-builder issue.

It usually is an electron builder issue.

The serialport object only works in the node server. You need to use a web
socket or something to get data to the browser.

On Thu, Aug 8, 2019 at 3:42 PM Rushinko notifications@github.com wrote:

I apologize I misinterpreted the first question I think. I am using node
with react so it’s rendering in chrome, however I’m still using node. Would
that still not work? I also have separate issues attempting it with
electron but I think that’s an electron-builder issue.

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/serialport/node-serialport/issues/1907?email_source=notifications&email_token=AAAGK3V4S2CTSMVSJXV4YRLQDRZKFA5CNFSM4IKKKTKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD34WFZI#issuecomment-519660261,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAGK3TLE3VFGPE6GGGC6ULQDRZKFANCNFSM4IKKKTKA
.

>


Francis Gulotta
[email protected]

So I managed to get the electron-rebuild to work. However when i try and run i get this error message:
image

I've tried updating my node with npm install -g n but that didn't fix anything. I've tried removing serialport from the project and re-adding it and using electron-rebuild, still didn't work. Any ideas?

It usually is an electron builder issue. The serialport object only works in the node server. You need to use a web socket or something to get data to the browser.
On Thu, Aug 8, 2019 at 3:42 PM Rushinko @.*> wrote: I apologize I misinterpreted the first question I think. I am using node with react so it’s rendering in chrome, however I’m still using node. Would that still not work? I also have separate issues attempting it with electron but I think that’s an electron-builder issue. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1907?email_source=notifications&email_token=AAAGK3V4S2CTSMVSJXV4YRLQDRZKFA5CNFSM4IKKKTKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD34WFZI#issuecomment-519660261>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAGK3TLE3VFGPE6GGGC6ULQDRZKFANCNFSM4IKKKTKA .
-- --- Francis Gulotta [email protected]

@Rushinko What version of Electron are you using? That error usually happens when serialport/bindings (or another native binary) is compiled against a different version of Node from the version running the program.

@Rushinko What version of Electron are you using? That error usually happens when serialport/bindings (or another native binary) is compiled against a different version of Node from the version running the program.

@HipsterBrown I am using v6.0.1, how can I recompile the native binaries to the target version? I thought that was electron-rebuild's purpose.

@Rushinko It appears this could be an issue with electron-rebuild and electron https://github.com/electron/electron-rebuild/issues/314

@HipsterBrown I created a new project and migrated the code over and installed serialport, electron and electron rebuild again and it is working now.

Thank you everyone for your help

Was this page helpful?
0 / 5 - 0 ratings

Related issues

callen5914 picture callen5914  Â·  7Comments

jbollacke picture jbollacke  Â·  6Comments

vkuehn picture vkuehn  Â·  6Comments

HemantJoshi picture HemantJoshi  Â·  4Comments

apiel picture apiel  Â·  5Comments