nklayman / vue-cli-plugin-electron-builder

Easily Build Your Vue.js App For Desktop With Electron
https://nklayman.github.io/vue-cli-plugin-electron-builder/
MIT License
4.12k stars 277 forks source link

Native module prebuilds not found when launching electron #737

Closed timgoeller closed 4 years ago

timgoeller commented 4 years ago

Describe the bug I'm using a module that uses sodium-native in my project. It comes with prebuilds. When starting the project I get an error, that no native build was found for my platform. That's because when it runs the index.js of the node-gyp-build located inside the sodium-native module from the index.js in dist_electron, the dir var in the node-gyp-build index.js file is the dist_electron dir where it won't find the prebuilds. Is there an additional step required to use that module?

To Reproduce Create a new project with vue-cli-plugin-electron-builder, install the hypercore module and import it in background.js.

nklayman commented 4 years ago

Try adding sodium-native as an external by setting your vue.config.js to:

module.exports = {
  pluginOptions: {
    electronBuilder: {
      externals: ['sodium-native']
    }
  }
}
timgoeller commented 4 years ago

I tried that, and it worked when using sodium-native on itself. It failed with an AssertionError when using the hypercore module however (which relies on the sodium-native module).

Works when adding hypercore to the externals though, so I'll close the issue.