Skip to content

better-sqlite3 native module incompatibility on Node runtime upgrade (e.g. Node 26) #3476

Description

@Rahulsharma0810

Describe the bug

When omniroute is installed globally via npm install -g omniroute on macOS, and the active Node.js version is subsequently updated or differs from the installation version (e.g., updating to Node v26.3.0 which uses NODE_MODULE_VERSION 147), the better-sqlite3 native module fails to load because it was compiled against a different version (e.g., NODE_MODULE_VERSION 127).

While OmniRoute gracefully detects this incompatibility and outputs a troubleshooting message:

✖ better-sqlite3 native module is incompatible with this platform.
  Run: cd /opt/homebrew/lib/node_modules/omniroute/dist && npm rebuild better-sqlite3

This failure causes background launchd services (such as com.rvs.omniroute.plist system/user daemons) to fail to start and crash repeatedly (exiting with code 1), making it hard to diagnose without manually reading logs or running the command directly in the shell.

To Reproduce

  1. Install omniroute globally using Node 22: npm install -g omniroute
  2. Update/switch Node version to v26.3.0.
  3. Start the service (or run omniroute).
  4. See dlopen failure warning and process exit code 1.

Possible Solutions / Suggestions

  1. Self-Healing / Auto-Rebuild: If the CLI detects !isNativeBinaryCompatible(sqliteBinary) and the environment has write permissions to the directory, trigger/prompt npm rebuild better-sqlite3 automatically, or add a recovery command like omniroute repair.
  2. Launchd Troubleshooting / Documentation: Add notes in the documentation about running npm rebuild better-sqlite3 when Node is updated.

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