electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.72k stars 1.74k forks source link

Unable to run .exe file created for windows using electron-packager and electron-builder #6774

Closed gyanig closed 2 years ago

gyanig commented 2 years ago

I am trying to generate executable file for windows in electronJs. For this I used electron-builder and electron-packager. After running command (npm run package-win) it generate release-build folder with .exe file but when I try to run this .exe file then its giving import error (screenshot attached). ss1

As I explored on google and found that for this we can use "type": "module" in package.json or with script tag. I also tried this solution but getting another error(screenshot attached) ss2

Additional Information:-

Package.json =>

{ "name": "audittoolapp", "author": "TalentWorldGroup Plc", "version": "0.1.0", "private": true, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint", "electron:build": "vue-cli-service electron:build", "electron:serve": "vue-cli-service electron:serve", "postinstall": "electron-builder install-app-deps", "postuninstall": "electron-builder install-app-deps", "package-win": "electron-packager . audittoolapp --overwrite --asar --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName='audittoolapp'", "package-linux": "electron-packager . electron-tutorial-app --overwrite --asar=true --platform=linux --arch=x64 --icon=assets/icons/png/1024x1024.png --prune=true --out=release-builds", "package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds" }, "main": "src/background.js", "dependencies": { "axios": "^0.21.1", "core-js": "^3.6.5", "electron-packager": "^15.4.0", "html2pdf.js": "^0.9.2", "keytar": "^7.9.0", "os": "^0.1.1", "systeminformation": "^5.6.10", "vue": "^2.6.11", "vue-ellipse-progress": "^1.3.0", "vue-router": "^3.2.0", "vuex": "^3.4.0" }, "devDependencies": { "@vue/cli-plugin-babel": "^4.5.0", "@vue/cli-plugin-eslint": "^4.5.0", "@vue/cli-service": "^4.5.0", "babel-eslint": "^10.1.0", "dotenv-webpack": "^7.1.0", "electron": "^11.0.0", "electron-builder": "^22.14.13", "electron-devtools-installer": "^3.1.0", "eslint": "^6.7.2", "eslint-plugin-vue": "^6.2.2", "vue-cli-plugin-electron-builder": "^2.0.0-rc.6", "vue-template-compiler": "^2.6.11" } }

vue.config.js =>

`const Dotenv = require('dotenv-webpack');

module.exports = { configureWebpack: { plugins: [ new Dotenv() ] }, publicPath: process.env.NODE_ENV === 'production' ? './' : '/' }

module.exports = { pluginOptions: { electronBuilder: { nodeIntegration: true, externals: ['keytar'] } } } `

gyanig commented 2 years ago

I also tried different versions of electron (14.2.9, 15.2.0 and 18) as electron community said but still errors not resolved.

mmaietta commented 2 years ago

Sorry, this project is electron-builder and you're using electron-packager. My best guess is that you have something incorrect with your vue-cli-service config as you're running into a compilation/bundling error, not one related to packaging.