Electron Project cannot file with correct path - electron

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');

Related

Can't run Electron app - EINVAL: invalid argument, lstat

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.

Electron-packager does not package node modules which names are started from "#"

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...

Error while Packaging and Distributing Electron Desktop Apps in Windows

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.

Electron packaging with electron-packager - missing files in the build output

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 ;)

install package with bower components is not correctly

I have this code in my webstorm IDE in the Terminal dialog:
bower install angular-ui-router
When I look now in my app/bower_components folder I can see the new created folder with angular-ui-router package.
But what I would have expected is also an entry in the bower.json file:
{
"name": "app",
"version": "0.0.0",
"dependencies": {
"angular": "1.2.6",
"json3": "~3.2.6",
"es5-shim": "~2.1.0",
"jquery": "~1.10.2",
"bootstrap": "~3.0.3",
"angular-resource": "1.2.6",
"angular-sanitize": "1.2.6",
"angular-route": "1.2.6",
"angular-bootstrap": "~0.10.0"
},
"devDependencies": {
"angular-mocks": "1.2.6",
"angular-scenario": "1.2.6"
}
}
I does not see the angular-ui-router anywhere!
Why is that?
You need to use the --save flag to get it in your bower.json:
bower install --save angular-ui-router

Resources