Skip to content

@electron/rebuild doesn't detect node-datachannel (cmake-js modules need rebuild script) #398

@akhileshthite

Description

@akhileshthite

Problem

node-datachannel uses cmake-js and prebuild-install, but @electron/rebuild (used by electron-builder) only detects node-gyp modules with a binding.gyp file. This causes architecture mismatches in Electron apps when building for multiple architectures (e.g., arm64 dev machine building x64 production builds).

Affected project: peersky-browser - @electron/rebuild skips node-datachannel during multi-arch builds, resulting in dlopen errors due to incorrect architecture binaries in packaged apps.

Electron versions:

    "electron": "^37.2.2",
    "electron-builder": "^26.0.12"

Current workaround
Electron apps need a script hook to manually run prebuild-install for each target architecture. peersky-browser temporarily implements this workaround until this issue is resolved upstream.

Current behavior

  • npm install runs prebuild-install and downloads the correct prebuild for the host architecture
  • @electron/rebuild skips node-datachannel because it only looks for binding.gyp
  • Packaged Electron apps get the wrong architecture binary (e.g., arm64 .node in x64 builds)

Proposed fix

Add a rebuild script to package.json:

{
  "scripts": {
    "install": "prebuild-install -r napi || (npm install --ignore-scripts --production=false && npm run _prebuild)",
    "rebuild": "prebuild-install -r napi || cmake-js rebuild"
  }
}

cc @murat-dogan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions