I am trying to generate a exe file with electron-builder not an installer so I am trying by setting the target to portable
{
"name": "hello-world",
"version": "1.0.0",
"description": "a hello world",
"main": "index.js",
"scripts": {
"start": "electron .",
"dist": "build"
},
"author": "KR",
"license": "ISC",
"devDependencies": {
"electron": "^4.1.4",
"electron-builder": "^20.39.0"
},
"build":{
"appId": "com.whatever.helloworld",
"win":{
"target": ["portable"],
"icon" : "build/icon.ico"
}
}
}
However when I try npm run dist I get
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
• electron-builder version=20.39.0
• loaded configuration file=package.json ("build" field)
• writing effective config file=dist\builder-effective-config.yaml
• no native production dependencies
• packaging platform=win32 arch=x64 electron=4.1.4 appOutDir=dist\win-unpacked
• default Electron icon is used reason=application icon is not set
• building target=portable file=dist\hello-world 1.0.0.exe archs=x64
and the program is stuck for ever. When I break it(ctrl-c), it says
Error: Exit code: 255. Command failed: D:\electrontest\hello-world\node_modules\7zip-bin\win\x64\7za.exe a -bd -mx=9 -mtc=off -mtm=off -mta=off D:\electrontest\hello-world\dist\hello-world-1.0.0-x64.nsis.7z .
So I guess the program is stuck in 7za compression.
I searched and there is no example of using electron-builder with portable only few with nsis. (I have another question but first I would like to run the basics).
use electron-builder from 1
then in package.json use in scripts:
"dist": "electron-builder --win=portable",
Related
After building the electron application using electron-builder, I cannot open the application from the dist folder. I did change all my links to use path.join(__dirname, "relative_path/") as what I have seen in some answers here. But I can't open the application even though the packaging process is successful.
File structure for the electron app project
Here's an image of my file structure, and this is the package.json file of the project
{
"name": "my_little_reminder",
"version": "0.5.0",
"description": "A simple time reminder app",
"main": "src/index.js",
"scripts": {
"start": "electron .",
"test": "jest --coverage",
"build": "electron-builder --dir"
},
"author": "Leonlit",
"license": "MIT",
"dependencies": {
"node-notifier": ">=8.0.1",
"node-schedule": "^1.3.2",
"sqlite3": "^5.0.0",
"electron-log": "^4.3.1"
},
"devDependencies": {
"electron": "^11.2.1",
"electron-builder": "^22.9.1",
"jest": "^26.6.3"
}
}
Finally, here's a link to the repository if the information here is not enough, https://github.com/Leonlit/My-Little-Reminder/tree/development
Resolved the issue by adding and using the npm script "postinstall": "electron-builder install-app-deps".
Then, using path.join(app.getPath('userData'), '/tasks.db') instead of path.join(__dirname, '/tasks.db') for the sqlite database storage location.
Finally, changed a link in the index file which caused the application to always request for saving a ASAR file on app launch if left unfixed.
My compiled app don't run and i don't know why ...
electron-installer-debian -> 3.0.0
node -> 8.16.0
npm -> 6.4.1
operating system ->ubuntu 16.04.6 amd64
I can compile the example app successfully.
I can compile my app successfully.
What did i do
package.json content
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"build": "electron-packager . electron-quick-start --platform linux --arch x64 --out dist/",
"deb64": "electron-installer-debian --src dist/electron-quick-start-linux-x64/ --dest dist/installers/ --arch amd64"
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "^8.2.5",
"electron-installer-debian": "^3.0.0",
"electron-packager": "^14.2.1"
}
}
I compile my app successfullt by executing npm run build to build my app with electron-packager then i do npm run deb64 to compile my code.
It return a successfull sentence.
Then i find my electron-quick-start_1.0.0_amd64.deb in the dist/installers folder and install it successfully (no error of any kind).
What did you expect to happen?
I expect to run my app by searching it in the ubuntu search bar.
What actually happened?
The app juste don't run. No error pop up. Nothing ... :'(
Even if i try to run it from terminal
see the image
electron-installer-debian creates dab file which by default installs your app in usr/lib folder. If you navigate to usr/lib//resources/ give permissions to your app folder your app should work, but this is not recommended for security reasons.
running the release script without publish option tries to publish the build to GitHub ( and fails while complaining about not being able to find GHToken! )
Error: GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN"
Setting "publish": "never" will fail also complaining about not being able to find module electron-publisher-never!
Error: Cannot find module 'electron-publisher-never'
It all happens while the project is built but build scripts exits non-zero!
I'm using the latest version of electron-builder.
my build script:
"build": {
"appId": "eu.armand.[****]",
"copyright": "Copyright © 2017 mim_Armand",
"productName": "[****]",
"mac": {
"publish": "never",
"category": "public.app-category.[****]",
"icon": "assets/icons/mac/icon.icns"
}
Any idea what's going on or if I'm doing it wrong?!
,m
try building with
"build": "electron-builder --publish never"
to never publish.
rename your script to something else.
if the script name is release → publish is set to always
the documentation states this:
CLI --publish option values:
...
If npm script named release, — always.
Add to scripts in the development package.json:
"release": "build"
and if you run yarn release, a release will be drafted (if doesn’t
already exist) and artifacts published.
I solved it this way, because I didn't need to put it in any repository
"build":{
"appId": "XXX",
"productName": "XXX",
"directories":{
"output": "build"
},
"win":{
"target": "nsis",
"publish" : []
}
}
https://www.electron.build/configuration/publish
Since the current VS code doesn't support Electron v1.6, so I have to downgrade my Electron version. However, I found that I can not install the old version of Electron by giving the version number in the package.json file. The following is my configuration:
{
"name": "Example",
"version": "1.0.0",
"description": "",
"main": "./app/main.js",
"scripts": {
"postinstall": "install-app-deps",
"start": "electron ."
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"electron-builder": "^15.5.1",
"electron": "^1.4",
"electron-rebuild": "^1.5.7"
},
"dependencies": {
"jquery": "^3.1.1",
"sqlite3": "^3.1.8"
}
}
The output of the npm install is the following:
And I run the following command to check the version of Electron:
node_modules/.bin/electron -v
and the output is '1.6.2' which is the latest version of Electron.
What's more interesting is that I can install the old version of Electron successfully by directly running the following command:
npm install electron#1.4
So I want to if there is anything wrong in my package.json file which caused this problem. And if so, how can I fix it.
Actually, the Electron version 1.6 satisfies "^1.4" because the caret tells NPM the minimal version of the package to install.
As also written in an answer to the Microsoft issue on GitHub, you might use "1.4" or "~1.4.0" in order to get Electron 1.4 or any other 1.4.x version (the tilde is for minimal minor releases as shown in the NPM documentation for the cli-based update of packages).
I'm trying to package my recent electron app. I tried to use electron-packager and I actually build the app though it is a bunch of files.
Now I'm facing some problems:
How do I change the app icon? I did it by setting its path in BrowserWindow creation, but shouldn't I be able to do it with electron packager?
And what about the actual desktop icon?
And finally how should I do to package all the files built by electron-packager in one .exe?
I'm building it in windows for windows architecture.
Oh i have faced that problem. first of all i'll leave you an example of how to use the API of electron-packager
var packager = require('electron-packager');
var options = {
'arch': 'ia32',
'platform': 'win32',
'dir': './',
'app-copyright': 'Paulo Galdo',
'app-version': '2.0.5',
'asar': true,
'icon': './app.ico',
'name': 'TierraDesktop',
'ignore': ['./releases', './.git'],
'out': './releases',
'overwrite': true,
'prune': true,
'version': '1.3.2',
'version-string':{
'CompanyName': 'Paulo Galdo',
'FileDescription': 'Tierra de colores', /*This is what display windows on task manager, shortcut and process*/
'OriginalFilename': 'TierraDesktop',
'ProductName': 'Tierra de colores',
'InternalName': 'TierraDesktop'
}
};
packager(options, function done_callback(err, appPaths) {
console.log(err);
console.log(appPaths);
});
Here i left you the link with all the information. Electron packager API
And finally a module so you can build your installer easily, just follow their API.
Windows installer
electron-builder is an all in one packager that will create a Windows installer (or other platforms) and allow you to set icons and many other settings. It actually uses electron-packager as a dependency for the actual packaging.
https://github.com/electron-userland/electron-builder
In Package.json
{
"name": "APP_NAME",
"version": "6.1.0",
"description": "About APP",
"main": "main.js",
"scripts": {
"preinstall": "npm i -g electron-packager",
"start": "electron .",
"package-win32": "electron-packager ./ APP_NAME --overwrite --platform=win32 --arch=ia32 --icon=assets/YOUR_Icon.ico --out=release-builds --app-copyright=\"Copyright © COMPANY_NAME 2020\" --version-string.CompanyName=COMPANY_NAME"
},
"author": "YOUR NAME",
"license": "YOUR LICENSE",
"devDependencies": {
"electron": "^2.0.0",
"electron-packager": "^12.2.0"
}
}