Skip to content

Node-serialport does not work in electron v14 or v15 #2313

@udik-chudik

Description

@udik-chudik

Hi!
After upgrading electron to version 14.0.0 in my project, electron-builder starts to break my builds. It took me about 3 hours to figure out what is going on, so I decide to write this issue to save someone else time:

Conditions:

  1. Electron 14.0.0
  2. electron-builder 22.11.7
  3. electron-rebuild 3.2.3
  4. serialport 9.2.1
  5. node 14.15.4
  6. npm 7.21.0

First step, try to build up the app:

$ ./node_modules/.bin/electron-builder

• electron-builder  version=22.11.7 os=5.4.0-81-generic
  • loaded configuration  file=package.json ("build" field)
  • electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies

To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • writing effective config  file=builds/builder-effective-config.yaml
  • rebuilding native dependencies  dependencies=@serialport/[email protected] platform=linux arch=x64
  • install prebuilt binary  name=@serialport/bindings version=9.2.1 platform=linux arch=x64 napi=
  • packaging       platform=linux arch=x64 electron=14.0.0 appOutDir=builds/linux-unpacked
..... etc, all ok .....

Second: try to run the app (or builded unpacked one) and got the error:

$  ./node_modules/.bin/electron ./dist/main.js
/home/project/node_modules/electron/dist/electron ./dist/main.js: symbol lookup error: /home/project/node_modules/@serialport/bindings/build/Release/bindings.node: undefined symbol: _ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeEPKNS_9CFunctionE

Solution:

$ ./node_modules/.bin/electron-rebuild -f
... compilation process ...
$ ./node_modules/.bin/electron ./dist/main.js
... all ok ...

If I try to electron-builder again, I will got the same error. I figured out that the problem is in serialport prebuild, exactly in bindings-v9.2.1-electron-v89-linux-x64.tar.gz that is being downloaded by electron-builder. I managed to successfully build my app only after following steps, to prevent prebuild binaries being downloaded:

$ ./node_modules/.bin/electron-rebuild -f
$ ./node_modules/.bin/electron-builder -c.npmRebuild=false

After downgrading Electron to 13.3.0, all works as expected: electron-builder downloads precompiled binaries (v89) and they work okay, nothing breaks.

So, is it okay that bindings-v9.2.1-electron-v89 does not work with Electron v14.0.0?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions