I have created a sample Electron App and i need to create a .exe file from it. I managed to build the app without errors but when i start the app an error appears.I cant figure out why im getting this.How to resolve this?.
The Error im getting
My package.json file
{
"name": "wordsum",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron main.js",
"package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=App/assets/WSlogo.icns --prune=true --out=release-builds",
"build": "electron-packager . --overwrite --asar=true --platform=win32 --arch=ia32 --icon=App/assets/WSlogo.ico --prune=true --out=release-builds --version-string.CompanyName=DevX --version-string.FileDescription=DevX --version-string.ProductName=\"WordSum\"",
"package-linux": "electron-packager . --overwrite --platform=linux --arch=x64 --icon=App/assets/WSlogo.png --prune=true --out=release-builds"
},
"author": "Thaaraka Romesh",
"license": "MIT",
"dependencies": {
"angular": "^1.6.2",
"bootstrap": "^3.3.7",
"jquery": "^3.1.1"
},
"devDependencies": {
"electron": "^1.4.15",
"electron-packager": "^8.5.1"
}
}
The Repo of the project Electron project
I found out whats wrong. In my package.json file its mentioned as "main": "index.js" but im my app the actual main file is called main.js.
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.
I have the following function that is trying to load a .ejs file with the following path.
function PaintNewOpponent() {
ejs.renderFile('views/NewOpponent.ejs', {pPlayer:pPlayerLocal}, function(err, str) {
$("#AddPlayerDialog").html(str);
alert(err)
RenderEvents();
FillInModalinformation()
});
}
I have run an alert check with __dirname and have discovered that I am in the correct directory. Here is a screenshot of my explorer window from Visual Studio Code.
the directory html is in my root directory. __dirname returns that I am in /html/js. PaintNewOpponent() is inside my NewOpponent.js file. Yet the ejs.renderFile call comes back in error saying it cannot file the file. Everything is in place.
If necessary here is package.json file
{
"name": "combattracker",
"version": "3.0.0",
"description": "AutoHARP 3: Combat Tracker",
"main": "index.js",
"license": "ISC",
"scripts": {
"start": "electron .",
"package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",
"package-win": "electron-packager . electron-tutorial-app --overwrite --asar=true --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=\"AutoHARP 3\"",
"package-linux": "electron-packager . electron-tutorial-app --overwrite --asar=true --platform=linux --arch=x64 --icon=assets/icons/png/icon.png --prune=true --out=release-builds"
},
"author": "David Klecker",
"dependencies": {
"bootstrap": "^4.5.2",
"bootstrap-sass": "^3.4.1",
"commonjs": "0.0.1",
"ejs": "^3.1.5",
"electron": "^10.1.2",
"electron-alert": "^0.1.11",
"electron-reload": "^1.5.0",
"embed-js": "^5.0.4",
"jquery": "^3.5.1",
"parser": "^0.1.4",
"popper.js": "^1.16.1",
"uniter": "^2.16.0",
"xml2js": "^0.4.23",
"xmlbuilder": "^15.1.1"
},
"devDependencies": {
"electron-packager": "^15.1.0"
}
}
I don't know if this will help but what I do is to build an absolute path using the path library (actually I use upath for cross platform compatibility because I often need to save the path to a file).
const iconPath = upath.joinSafe(__dirname, 'app', 'assets', 'win_icon_64x64.png');
I'm getting the following error whenever I try to run my app:
My package.json:
{
"name": "SteamCMD-GUI",
"productName": "SteamCMD GUI",
"version": "0.0.1",
"main": "main.js",
"author": "avi12",
"scripts": {
"start": "electron .",
"package": "asar pack \"SteamCMD GUI-win32-x64\" \"SteamCMD GUI.asar\"",
"build-windows": "electron-packager . --platform=win32 --overwrite --out=release-builds --prune=true --icon=image/icon.ico --asar",
"build-linux": "electron-packager . --platform=linux --overwrite --out=release-builds --prune=true --icon=image/icon.png --asar",
"build-mac": "electron-packager . --platform=darwin --overwrite --out=release-builds --prune=true --icon=image/icon.icns --asar"
},
"dependencies": {
"bignumber.js": "^5.0.0",
"chokidar": "^1.7.0",
"decompress": "^4.2.0",
"electron": "^1.8.4",
"electron-dl": "^1.11.0",
"fs-jetpack": "^1.3.0",
"jquery": "^3.3.1",
"node-fetch": "^1.7.3",
"onsenui": "^2.9.2",
"sudo-prompt": "^7.1.1",
"tooltip.js": "^1.2.0"
}
}
How can I solve this?
Searching for that error led me here, which suggests that it's a problem in libuv, an IO library used by Node. This issue is fixed in a later version of libuv, which is used by a later version of Node, which is used by a later version of Electron.
Updating to Electron 2.0 solves this issue.
I create desktop application by using electron, and tried electron-packager.
But electron-packager doesn't package node modules which names are started from "#" (Example: #turf, #mapbox)
In node_modules folder of developing folder, I can find "#turf" and "#mapbox".
But after running
>electron-packager . MaplatEditor --platform=darwin --arch=x64 --electron-version=1.7.9
Created package never includes "#turf" and "#mapbox".
And also, it's depending modules are also not included.
My package.json includes "#turf", so it is not setting error.
{
"name": "MaplatEditor",
"version": "1.0.0",
"description": "",
"main": "lib/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#turf/turf": "^4.6.1",
"argv": "0.0.2",
"async": "^2.5.0",
"child_process": "^1.0.2",
"electron-json-storage": "^3.2.0",
"file-url": "^2.0.2",
"fs-extra": "^3.0.1",
"imagemagick": "^0.1.3",
"mapshaper": "^0.4.31",
"path": "^0.12.7",
"wellknown": "^0.5.0"
}
}
How can I package such #-started modules into application package?
In my case, I updated #Turf module for latest version, then electron-packager worked well.
I don't know why, but it looks not the issue of electron-packager...
here is my build command. current folder has additiona files like settings.config, readme.md these files are not included in the build output.
"build-win": "electron-packager . AppName --overwrite --out=dist --ignore='^/dist$' --prune --asar --platform=win32 --arch=all --version=0.36.0 --icon=img/favicon.ico"
This is the package.json
{
"name": "ElectronDesktopTest",
"productName": "ElectronDesktopTest",
"version": "1.0.0",
"description": "Electron Desktop Test",
"main": "main.js",
"electronVersion": "0.36.0",
"scripts": {
"start": "electron main.js",
"build-win": "electron-packager . ElectronDesktopTest --overwrite --out=dist --ignore='^/dist$' --prune --asar --platform=win32 --arch=all --version=0.36.0 --icon=img/favicon.ico"
},
"author": "Jyo",
"devDependencies": {
"electron-prebuilt": "^0.36.0",
"electron-packager": "^5.2.0"
},
"dependencies": {
"electron-reload": "^0.2.0",
"fs-extra": "^0.26.5",
"gray-matter": "^2.0.2",
"jade": "^1.11.0",
"jquery": "^2.2.0",
"lunr": "^0.6.0",
"showdown": "^1.3.0",
"underscore": "^1.8.3"
}
}
If question tagged electron-builder, you can try to use electron-builder ;)