question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using the webpack plugin, unable to find native modules

See original GitHub issue
  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue:

Repro here: https://github.com/nornagon/electron-forge-native-module-repro

When using @electron-forge/plugin-webpack and importing serialport, an error is thrown when the serialport module tries to load its native module:

Error: Could not locate the bindings file. Tried:
 → /Users/nornagon/Source/plotter/saxi/build/bindings.node
 → /Users/nornagon/Source/plotter/saxi/build/Debug/bindings.node
 → /Users/nornagon/Source/plotter/saxi/build/Release/bindings.node
 → /Users/nornagon/Source/plotter/saxi/out/Debug/bindings.node
 → /Users/nornagon/Source/plotter/saxi/Debug/bindings.node
 → /Users/nornagon/Source/plotter/saxi/out/Release/bindings.node
 → /Users/nornagon/Source/plotter/saxi/Release/bindings.node
 → /Users/nornagon/Source/plotter/saxi/build/default/bindings.node
 → /Users/nornagon/Source/plotter/saxi/compiled/10.11.0/darwin/x64/bindings.node
 → /Users/nornagon/Source/plotter/saxi/addon-build/release/install-root/bindings.node
 → /Users/nornagon/Source/plotter/saxi/addon-build/debug/install-root/bindings.node
 → /Users/nornagon/Source/plotter/saxi/addon-build/default/install-root/bindings.node
 → /Users/nornagon/Source/plotter/saxi/lib/binding/node-v69-darwin-x64/bindings.node
    at bindings (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:2699:9)
    at Object../node_modules/@serialport/bindings/lib/darwin.js (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:338:91)
    at __webpack_require__ (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:21:30)
    at Object../node_modules/@serialport/bindings/lib/index.js (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:460:22)
    at __webpack_require__ (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:21:30)
    at Object../node_modules/serialport/lib/index.js (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:21113:17)
    at __webpack_require__ (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:21:30)
    at Module../src/ebb.ts (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:25513:68)
    at __webpack_require__ (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:21:30)
    at Module../src/server.ts (/Users/nornagon/Source/plotter/saxi/.webpack/main/index.js:26256:62)

What does your config.forge data in package.json look like?

  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [/* ... */],
      "plugins": [
        [
          "@electron-forge/plugin-webpack",
          {
            "mainConfig": "./webpack.main.config.js",
            "renderer": {
              "config": "./webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./src/index.html",
                  "js": "./src/ui.tsx",
                  "name": "main_window"
                }
              ]
            }
          }
        ]
      ]
    }
  },

Please provide either a failing minimal testcase (with a link to the code) or detailed steps to reproduce your problem. Using electron-forge init is a good starting point, if that is not the source of your problem.

https://github.com/nornagon/electron-forge-native-module-repro

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
CraigMasoncommented, Sep 17, 2019

Hi @MarshallOfSound

Just spent a few hours trying to find the best way to import multiple native modules. I am developing one locally, and have used npm link. This causes the native module in the linked module to be omitted using your example above.

I also note that your fork is some commits behind @zeit/webpack-asset-relocator-loader.

I’m currently resorting to using CopyWebpackPlugin and webpack.NormalModuleReplacementPlugin to provide my own implementation of bindings.js (which many modules use).

Just wondering if there’s a better solution?

1reaction
jrobesoncommented, Feb 26, 2019

yes, this is for native modules. i’m using a native module with that exact configuration. I’m not asking for support. I just wanted to share a working configuration. Can you explain how that is offtopic for this particular thread?

Read more comments on GitHub >

github_iconTop Results From Across the Web

When using the webpack plugin, unable to find native modules
I'm currently resorting to using CopyWebpackPlugin and webpack.NormalModuleReplacementPlugin to provide my own implementation of bindings.js ( ...
Read more >
Webpack: Unable to find module with ID: main -- (Aurelia App)
EDIT: After a debugging session, the issue with module with ID: main not found was simply resolved by changing Webpack AureliaPlugin to its ......
Read more >
Module Federation - webpack
This plugin creates an additional container entry with the specified exposed modules. ContainerReferencePlugin (low level). This plugin adds specific references ...
Read more >
copy-webpack-plugin - npm
But you should always use forward-slashes in glob expressions See fast-glob manual. module.exports = { plugins: [ new CopyPlugin ...
Read more >
How I solved and debugged my Webpack issue through trial ...
See the original at: ... My debugging journey started with the following setup: ... const path = require('path');const HtmlWebpackPlugin ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found