Skip to content

[Bug]: Cannot find native binding when using @tego/botjs in Electron application #13

@6xiaoxin

Description

@6xiaoxin

Version

0.2.0

Description of the issue

After installing @tego/botjs in my Electron project, the application fails to load and throws a "Cannot find native binding" error. The error suggests npm's optional dependency bug, but the issue persists even after cleaning dependencies and re-installing. The core problem is that the native module of @tego/botjs is not compatible with Electron's built-in Node.js environment.

@tego/botjs should be loaded normally in the Electron environment, without native binding missing errors.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a new Electron project (my version: 33.4.11)
  2. Initialize package.json (Node.js version: 25.1.0)
  3. Install @tego/botjs via pnpm add @tego/botjs (or npm install @tego/botjs)
  4. Try to start the Electron app (pnpm run dev)
  5. The app crashes with the "Cannot find native binding" error

Logs or error messages

App threw an error during load
Error: Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
    at file:///E:/code/electron/xunfei-dll-no-server/dist-electron/main-DEyYWW85.js:27093:11
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async loadApplicationPackage (file:///E:/code/electron/xunfei-dll-no-server/node_modules/.pnpm/electron@33.4.11/node_modules/electron/dist/resources/default_app.asar/main.js:129:9)
    at async file:///E:/code/electron/xunfei-dll-no-server/node_modules/.pnpm/electron@33.4.11/node_modules/electron/dist/resources/default_app.asar/main.js:242:9

Environment

  • OS: Windows 11
  • Node.js Version: v25.1.0
  • Electron Version: 33.4.11
  • @tego/botjs Version: 0.2.0
  • Package Manager: pnpm 10.20.0
  • Electron Builder Version : 25.1.8

Checklist

  • I have searched existing issues
  • I am using the latest version

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions