I am trying to make a snap for my little application “OpenSpeedTest-Server” This is a simple network performance estimation tool.
It is working fine on Windows, Mac and Linux (DEB). When i Export the same in Snap, Application unable to get the client device ip address.
i try “confinement”: “classic”, and plugs network observe etc. but nothing worked.
I added “#davidwinter/electron-forge-maker-snap” DevDependency manually and exporting it as snap actually working.
The only problem is application cannot get device ip address.
My Electron Forge package.json
{
"name": "OpenSpeedTest-Server",
"productName": "OpenSpeedTest-Server",
"version": "2.1.0",
"description": "Network Speed Test Server - by OpenSpeedTest",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "OpenSpeedTest",
"email": "support#openspeedtest.com"
},
"license": "MIT",
"config": {
"confinement": "devmode",
"forge": {
"packagerConfig": {
"icon": "src/icon.png"
},
"makers": [
{
"name": "#davidwinter/electron-forge-maker-snap",
"config": {
"name": "OpenSpeedTest_Server",
"categories": [
"Utility"
]
}
},
{
"name": "#electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "#electron-forge/maker-deb",
"config": {}
},
{
"name": "#electron-forge/maker-rpm",
"config": {}
}
]
}
},
"dependencies": {
"#davidwinter/electron-forge-maker-snap": "^2.0.4",
"cors": "^2.8.5",
"electron-squirrel-startup": "^1.0.0",
"express": "^4.17.1",
"internal-ip": "^6.2.0",
"tcp-port-used": "^1.0.2"
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.57",
"#electron-forge/maker-deb": "^6.0.0-beta.57",
"#electron-forge/maker-rpm": "^6.0.0-beta.57",
"#electron-forge/maker-squirrel": "^6.0.0-beta.57",
"#electron-forge/maker-zip": "^6.0.0-beta.57",
"electron": "13.1.2"
}
}
{
“name”: “#davidwinter/electron-forge-maker-snap”,
“config”: {
“name”: “OpenSpeedTest_Server”,
“categories”: [
“Utility”
],
“stagePackages”: [
“default”,
“iproute2”
]
}
},
My devDep.
},
"dependencies": {
"cors": "^2.8.5",
"electron-squirrel-startup": "^1.0.0",
"express": "^4.17.1",
"internal-ip": "^6.2.0",
"tcp-port-used": "^1.0.2"
},
Internal IP is responsible for getting ip address.
https://www.npmjs.com/package/internal-ip
The module returns the address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, undefined will be returned.
The module relies on operating systems tools. On Linux and Android, the ip command must be available, which depending on distribution might not be installed by default. It is usually provided by the iproute2 package. .v4.sync() and .v6.sync() are not supported in browsers and just return undefined.
so we need to add iproute2 in stagePackages for get this to work on snap.
Related
I am trying to make a Flatpak for my little application “OpenSpeedTest-Server”
This is a simple network performance estimation tool. It is working fine on Windows, Mac and Linux (DEB).
1) When i Export the same in Flatpak, Application unable to get the client device ip address.
2) Also i am not able to put a custom icon for my Flatpak.
I used electronforge.
Here is my package.json
{
"name": "OpenSpeedTest-Server",
"productName": "OpenSpeedTest-Server",
"version": "2.1.0",
"description": "Network Speed Test Server - by OpenSpeedTest",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "OpenSpeedTest",
"email": "support#openspeedtest.com"
},
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {
"icon": "src/icon.png"
},
"makers": [
{
"name": "#electron-forge/maker-flatpak",
"config": {
"name": "OpenSpeedTest_Server",
"options": {
"categories": [
"Utility"
],
"icon": "src/icon.png"
}
}
},
{
"name": "#electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "#electron-forge/maker-deb",
"config": {}
},
{
"name": "#electron-forge/maker-rpm",
"config": {}
}
]
}
},
"dependencies": {
"cors": "^2.8.5",
"electron-squirrel-startup": "^1.0.0",
"express": "^4.17.1",
"internal-ip": "^6.2.0",
"tcp-port-used": "^1.0.2"
},
"devDependencies": {
"#davidwinter/electron-forge-maker-snap": "^2.0.4",
"#electron-forge/cli": "^6.0.0-beta.57",
"#electron-forge/maker-deb": "^6.0.0-beta.57",
"#electron-forge/maker-flatpak": "^6.0.0-beta.57",
"#electron-forge/maker-rpm": "^6.0.0-beta.57",
"#electron-forge/maker-squirrel": "^6.0.0-beta.57",
"#electron-forge/maker-zip": "^6.0.0-beta.57",
"electron": "13.1.2"
}
}
How can i solve this issue?
Solved the issue by adding iproute2 to source and specifying icon dimension. Max supported was 512x512 and i was using 1024x1024
{
"name": "#electron-forge/maker-flatpak",
"config": {
"name": "OpenSpeedTest_Server",
"options": {
"categories": [
"Utility"
],
"icon": {
"512x512": "src/android-chrome-512x512.png"
}
},
"modules": [
{
"name": "zypak",
"sources": [
{
"type": "git",
"url": "https://github.com/refi64/zypak",
"tag": "v2021.02"
}
]
},
{
"name": "iproute2",
"make-install-args": [
"PREFIX=/app",
"CONFDIR=/app/share/iproute2",
"SBINDIR=/app/bin"
],
"sources": [
{
"type": "archive",
"url": "https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-5.7.0.tar.xz",
"sha256": "725dc7ba94aae54c6f8d4223ca055d9fb4fe89d6994b1c03bfb4411c4dd10f21"
}
],
"cleanup": [
"/include",
"/share/bash-completion",
"/share/man"
]
}
]
}
},
when I test to publish on github I get this error write ECONNRESET at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:87:16)
Here is my code
{
"name": "app",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"dist": "electron-builder",
"publish": "electron-builder --publish always"
},
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "^8.0.0",
"electron-builder": "^22.3.2"
},
"repository": {
"type" : "git",
"url" : "https://github.com/Fizo55/app.git"
},
"build": {
"appId": "com.fizo55.app",
"productName": "app",
"target": "NSIS",
"directories": {
"output": "build"
},
"publish": [
{
"provider": "github",
"private": true,
"owner": "Fizo55",
"repo": "app",
"token": "mytoken"
}
],
"nsis": {
"allowToChangeInstallationDirectory": true,
"oneClick": false
}
}
}
Thanks for your help
After some test, it was my connection the problem, I switched on my 4G and now it work perfectly.
I am getting the below error while making deb file of electronjs
Error: could not find the Electron app binary at "dist/app-linux-x64/koriwallet". You may need to re-bundle the app using Electron Packager's "executableName" option.
My package.json file is
{
"name": "wallet",
"version": "1.0.0",
"description": "wallet",
"main": "src/main.js",
"scripts": {
"start": "electron .",
"build": "electron-packager . myapp",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"deb64": "electron-installer-debian --src dist/app-linux-x64/ --dest dist/installers/ --arch amd64"
},
"author": "wallet",
"license": "ISC",
"devDependencies": {
"asar": "^2.0.1",
"electron": "^5.0.6",
"electron-builder": "^21.1.1",
"electron-installer-debian": "^2.0.0",
"electron-packager": "^14.0.2"
},
"electronPackagerConfig": {
"packageManager": "npm",
"executableName": "kori"
},
"build": {
"appId": "wallet",
"linux": {
"category": "wallet"
}
},
"dependencies": {
"cookies": "^0.7.3",
"crypto": "^1.0.1",
"dpkg": "^1.0.0",
"jquery": "^3.4.1",
"jstorage": "^0.4.8"
}
}
My 2 cents. I'm making an Fedora 30 rpm and got:
An unhandled error has occurred inside Forge:
An error occured while making for target: rpm
could not find the Electron app binary at "/home/ajm/Documents/Projects/sunstealer.ets/out/sunstealer.ets product-linux-x64/sunstealer.ets". You may need to re-bundle the app using Electron Packager's "executableName" option.
Error: could not find the Electron app binary at "/home/ajm/Documents/Projects/sunstealer.ets/out/sunstealer.ets product-linux-x64/sunstealer.ets". You may need to re-bundle the app using Electron Packager's "executableName" option.
at error.wrapError (/home/ajm/Documents/Projects/sunstealer.ets/node_modules/electron-installer-common/src/installer.js:145:15)
Fix was update package.json from
"name": "sunstealer.ets",
"productName": "sunstealer.ets product",
to:
"name": "sunstealer.ets",
"productName": "sunstealer.ets",
i.e. same value. Then npm run make with:
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"certificateFile": "./certs/adam_mauger.pfx",
"certificatePassword": "REDACTED"
}
},
{
"name": "#electron-forge/maker-dmg",
"config": {
"format": "ULFO"
}
},
{
"name": "#electron-forge/maker-rpm",
"config": {
}
},
created sunstealer.ets-1.0.0-1.x86_64.rpm. Hope that helps.
my 5 cents)
so, launch npm from root folder. there exist node_modules.
app stored in root/src. there exist node_modules.
and in root and in root/src have package.json
check root/src/package.json file. maybe there parameter "name" have default value in lowercase
This a strange one for me. I have an Electron app which works fine when I run it locally. However, when I npm run dist it to create a native version, the resulting app fails to take focus when I click on it. I click on the text field in the window and a flashing cursor shows up however, when I type keystrokes, they go to the window I was in before (e.g. Finder). This only happens in Mac (Windows works fine) when I'm using a packaged version.
Very perplexing stuff :)
My package.json looks like this (sanitised some names and URLs):
{
"name": "Myapp",
"productName": "MyApp",
"version": "0.0.44",
"description": "MyApp",
"license": "",
"repository": "",
"main": "./main.js",
"author": {
"name": "MyApp Ltd.",
"email": "c#c.com",
"url": "www.c.com"
},
"engines": {
"node": ">=4"
},
"electronVersion": "1.8.3",
"scripts": {
"test": "mocha",
"start": "electron .",
"pack": "build --dir",
"dist": "build"
},
"build": {
"appId": "MyApp",
"win": {
"target": "squirrel",
"icon": "assets/icons/Windows_Icon.ico"
},
"squirrelWindows": {
"loadingGif": "assets/img/installing.gif",
"iconUrl": "https:/fake-url.com/icon.ico",
"msi": false
},
"dmg": {
"window": {
"x": 200,
"y": 200,
"width": 537,
"height": 374
},
"icon": "assets/icons/Mac_Icon.icns",
"background": "assets/img/dmg-background.png"
},
"mac": {
"icon": "assets/icons/Mac_Icon.icns",
"extendInfo": {
"LSBackgroundOnly": 1
}
}
},
"dependencies": {
"azure-event-hubs": "0.0.4",
"babel-polyfill": "^6.20.0",
"bootstrap": "^3.3.7",
"chokidar": "^1.6.1",
"download": "^5.0.2",
"electron-debug": "^0.3.0",
"electron-is-dev": "^0.3.0",
"electron-json-storage": "^3.0.4",
"electron-log": "^2.2.6",
"electron-positioner": "^3.0.0",
"electron-squirrel-startup": "^1.0.0",
"follow-redirects": "^1.2.3",
"glob": "^7.1.1",
"howler": "^2.0.3",
"jquery": "^3.2.1",
"nan": "^2.1.0",
"nconf": "^0.7.2",
"node-schedule": "^1.2.5",
"opener": "^1.4.3",
"pusher-js": "^4.1.0",
"sqlite3": "^3.1.8",
"unirest": "^0.5.1"
},
"devDependencies": {
"chai": "^4.0.2",
"chai-as-promised": "^6.0.0",
"electron": "^1.8.3",
"electron-builder": "^20.8.0",
"electron-builder-squirrel-windows": "^20.9.0",
"electron-installer-dmg": "^0.2.1",
"electron-packager": "^5.1.1",
"mocha": "^3.2.0",
"spectron": "^3.0.0",
"xo": "^0.10.0"
},
"xo": {
"esnext": true,
"envs": [
"node",
"browser"
]
}
}
The LSBackgroundOnly option in Mac apparently has this effect because it designates the app a background app and presumably no events are delivered to it. Once I set it to false, the issue was resolved.
I am building my first electron app, but I cant package it.
When I am testing using npm start everything works but when I tried to package it and when it done, I run it, but I am getting something like this ENOENT: no such file or directory, lstat.
I have some source like this.
fs.copy(path.resolve('src/app/resource/'), dir + '/resource/', e => {
if (e) {
reject(e);
return;
}
resolve(true);
});
That will copy files to the specified directory and it seem this is the cause of the error.
Edit:
I enable the devtools and create installer for windows, but just got this.
It seems my files is not included on the build.
this is my package.json
{
"name": "exporter",
"productName": "Exporter",
"version": "0.0.1",
"description": "",
"license": "MIT",
"repository": "",
"author": {
"name": "",
"email": "",
"url": "none"
},
"scripts": {
"start": "electron .",
"build": "electron-packager . --out=/mnt/Busy\\ Drive/dist/exporter --asar --overwrite --all",
"pack": "build --dir",
"dist": "build -wl"
},
"dependencies": {
"bootstrap": "^4.0.0-beta",
"config": "^1.28.1",
"electron-debug": "^1.0.0",
"fs-extra": "^4.0.2",
"is-electron-renderer": "^2.0.1",
"jquery": "^3.2.1",
"mysql": "^2.15.0",
"popper.js": "^1.13.0",
"winston": "^2.4.0"
},
"devDependencies": {
"devtron": "^1.1.0",
"electron": "^1.8.1",
"electron-builder": "^19.47.1",
"electron-builder-squirrel-windows": "^19.47.0",
"electron-packager": "^8.0.0",
"eslint": "^4.11.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1"
},
"build": {
"appId": "no-id",
"linux": {
"target": [
"dir"
]
},
"win": {
"target": "nsis"
}
}
}
I already tried different packager but still without success.
Is there wrong on my package.json?
The culprit is using the path.resolve, you should usepath.join(__dirname, 'your/path/here'), so it can access the asar file.