electron-builder
electron-builder copied to clipboard
npmRebuild config does not have an effect
- Electron-Builder Version: 23.0.3
- Node Version: 16.16.0
- Electron Version: 20.0.3
- Electron Type (current, beta, nightly): current
- Target: MacOS Catalina 10.15.7
I am trying to use fabric within my Electron application. When I install it using npm install fabric --save
everything works and I can use it both in development and in production. But when I type in npm install
for the project, it runs into some issues:
> [email protected] postinstall
> electron-builder install-app-deps
• electron-builder version=22.14.13
• rebuilding native dependencies [email protected] platform=darwin arch=x64
⨯ cannot execute cause=exit status 1
errorOut=npm ERR! code 1
So my Electron app is running a postinstall script that tries to rebuild native dependencies, in this case, node-canvas which is used by fabric but throws an error for some reason.
I tried to stop electron-builder from building native dependencies, but the npmRebuild command does not have any effect. Here is my electron-builder configuration. I am using electron-builder as part of vue-cli-plugin-electron-builder but the electron-builder config is proxied through.
vue.config.js
...
electronBuilder: {
mainProcessFile: 'src/background.js',
mainProcessWatch: ['src/*.js'],
preload: 'src/preload.js',
extends: null,
builderOptions: {
appId: 'com.exploo.capture',
npmRebuild: false,
win: {
icon: 'public/img/icon.png'
},
mac: {
icon: 'public/img/icon.png'
}
},
externals: ['ffmpeg-static', 'ffprobe-static'],
nodeModulesPath: ['./node_modules'],
// needed to work with ffmpeg
chainWebpackMainProcess: config => {
config.plugin('define').tap(args => {
args[0]['process.env.FLUENTFFMPEG_COV'] = false
return args
})
}
}
I also tried to put the npmRebuild: false in the other blocks - still not working.
I am seeing two options - both do not work at the moment:
- Ideally node-canvas needs to have some prebuilds available for electron, correct? I created this ticket in the node-canvas issues. But not sure when the node-canvas maintainers will tackle it.
- I tried
npmRebuild: false
like shared above to disable the rebuilding of native dependencies, but it does not have an effect as described above.
So I am stuck.
vue-cli-plugin-electron-builder uses an old version of electron-builder ("electron-builder version=22.14.13" in the CLI logs), please force an updated version of electron-builder via yarn resolutions
or npm overrides
You can also get debug logs via DEBUG=electron-builder
I'd also recommend trying config buildDependenciesFromSource: true
to see if that helps
Updated to newest electron-builder, but no effect of npmRebuild: false
in config. I also tried buildDependenciesFromSource: true
which does not have an impact, too.
FYI: I am calling "postinstall": "electron-builder install-app-deps"
in my package.json. Doesnt the npmRebuild: false
command disable this by config? What can happen if I leave "postinstall": "electron-builder install-app-deps"
out?
npmRebuild
doesn't disable electron-builder install-app-deps
as the latter is using cmd line and directly executing npm rebuild, whereas the former is only used to the electron-builder packaging process.