Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native module bindings not available in executable #776

Closed
vostrnad opened this issue Jun 10, 2020 · 3 comments
Closed

Native module bindings not available in executable #776

vostrnad opened this issue Jun 10, 2020 · 3 comments
Labels

Comments

@vostrnad
Copy link

What happened:
I am using the serialport library. When I build an executable that uses it, it seems like it's looking for some native binding files in node_modules outside its virtual filesystem. This means that once I move the executable somewhere else (e.g. C:\), it throws this error on startup:

C:\node_modules\bindings\bindings.js:211
      throw new Error(
      ^

Error: Could not find module root given file: "C:\node_modules\@serialport\bindings\lib\win32.js". Do you have a `package.json` file?
    at Function.getRoot (C:\node_modules\bindings\bindings.js:211:13)
    at bindings (C:\node_modules\bindings\bindings.js:82:32)
    at Object.<anonymous> (C:\node_modules\@serialport\bindings\lib\win32.js:1:36)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\node_modules\@serialport\bindings\lib\index.js:6:22)

What you expected to happen:
Expected the serialport module to load correctly.

How to reproduce it (as minimally and precisely as possible):

  • npm install serialport@9.0.0
  • In your index.js:
require('serialport')
  • nexe index.js -o app.exe
  • Move app.exe somewhere else so it doesn't see the node_modules folder.
  • Start app.exe.

Environment:

  • Platform(OS/Version): Windows 10 64bit
  • Host Node Version: 12.13.1
  • Target Node Version: 12.13.1
  • Nexe version: 3.3.2
  • Python Version: 3.8.1
@luzlab
Copy link

luzlab commented Jun 17, 2020

What happens if you move the node_modules folder to the same place as app.exe? I think this might be a known issue.

@calebboyd
Copy link
Member

Native modules need to be shipped alongside the binary since they are required to be linked from filesystem with dlopen. The process for linking a dynamic library from memory is not universal across platforms. While it is technically possible, this capability has not been added to nexe or prioritized due to the scope involved in creating and maintaining it.

@calebboyd
Copy link
Member

PRs welcome 👍 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants