make electron execute itself in run version (npx electron .) - electron

my app create another instance with some parameters:
exec(remote.process.argv[0] + " " + parameter)
In build version, it works perfect.
In dev version (npx electron .), it doesn't work.
So I need to re-build everytime.
How can I make my code work in dev version?
In dev version:
> remote.process.argv[0]
< "C:\Users\xxx\Downloads\node\editor3\node_modules\electron\dist\electron.exe"
It seems it doesn't run my app in dev version.
It just opens a default (empty) electron and put my parameter inside it without loading my app (index.html).
package.json:
{
"name": "editor",
"version": "0.1.0",
"main": "main.js",
"dependencies": {
"markd": "^1.2.0",
"marked": "^0.3.6"
},
"devDependencies": {
"electron": "^8.2.1",
"electron-packager": "^14.2.1"
},
"scripts": {
"start": "electron .",
"build": "electron-packager ."
}
}
$ npm -v
6.4.1
$ node -v
v10.15.3

Related

npm run make is not working in electron-forge

I have created and electron application and trying to use electron forge for building purpose.
Please find below command which i have run it for creating the electron application:
#npm i -g create-react-app
#npm i -g #electron-forge/cli
#npx create-electron-app my-ele-app
The above last command created a project my-ele-app. and now i am able to start the application as well.
#npm start.
content of package.json file is:
{
"name": "my-ele-app",
"productName": "my-ele-app",
"version": "1.0.0",
"description": "My Electron application description",
"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": "rohit",
"email": "rohit#xyz.com"
},
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"name": "my_ele_app"
}
},
{
"name": "#electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "#electron-forge/maker-deb",
"config": {}
},
{
"name": "#electron-forge/maker-rpm",
"config": {}
}
]
}
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.55",
"#electron-forge/maker-deb": "^6.0.0-beta.55",
"#electron-forge/maker-rpm": "^6.0.0-beta.55",
"#electron-forge/maker-squirrel": "^6.0.0-beta.55",
"#electron-forge/maker-zip": "^6.0.0-beta.55",
"electron": "12.0.9"
}
}
Now when i am running below command, it is throwing error:
#npm run make
Error is:
> my-ele-app#1.0.0 make
> electron-forge make
√ Checking your system
√ Resolving Forge Config
An unhandled rejection has occurred inside Forge:
Error: Could not find module with name: #electron-forge/maker-squirrel. Make sure it's listed in the devDependencies of your package.json
at _default (C:\Users\212807091\Desktop\Rohit\Office Note\RBAC\Electron_project\npx_electrong\my-ele-app\node_modules\#electron-forge\core\src\api\make.ts:125:15)
at C:\Users\212807091\Desktop\Rohit\Office Note\RBAC\Electron_project\npx_electrong\my-ele-app\node_modules\#electron-forge\cli\src\electron-forge-make.ts:44:5
Electron Forge was terminated. Location:
{}
NOTE: i can see there is module available in node_modules folder:
my-ele-app\node_modules#electron-forge\maker-squirrel
If anyone here has any idea how to fix this issue. please provide the answer. Thanks!
In my cases, it makes error when the description or author is empty in package.json file.
I got the same error after following the "Getting Started" instructions. Nothing resolved it until I ran npm install -g #electron-forge/cli#beta -- after that finished I was able to successfully run electron-forge make.
Also running npm run make did the same as electron-forge make as I didn't appear to have it installed. Another thing I noticed is that if I run npm run make with maker-squirrel at version 6.0.0-beta.55 then I get this error: Could not find module with name: #electron-forge/maker-squirrel. However, if I re-install maker-squirrel as npm install --save-dev #electron-forge/maker-squirrel#6.0.0-beta.33 and re-run npm run make then I get an out folder with an exe.
you have installed all the required dependencies so just run this command
npm run package
And after this a folder with name out is generated and inside that your .exe file will be present
I had a similar issue but I followed the instructions from here: https://www.electronjs.org/docs/latest/tutorial/quick-start#package-and-distribute-your-application
I missed calling npx electron-forge import. So the full pipeline looks like this:
npm install --save-dev #electron-forge/cli
npx electron-forge import
npm run make
Check the documentation. i solve same problem with this
If you are using Windows, this works for me:
Run npm i electron-winstaller --save-dev --ignore-scripts
Install 7zip x86 in your computer. After installed, go to C:\Program Files (x86)\7-Zip and copy both 7z.dll and 7z.exe files to /path/to/your_project/node_modules/electron-winstaller/vendor if they are not still there.
Run npm electron-forge import again
Then try run npm run make again. I hope it works.

Unable to open electron app after packaging the app using electron-builder

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.

electron-installer-debian compiled app .deb won't run

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.

node modules not found after packaging electron app with electron-forge for window

Electron app was initialized using electron-forge webpack template and everything works perfectly for macOs.
While running the dev version using electron-forge start the app loads perfectly on windows.
Once the app is packaged for windows using electron-forge make the build completes successfully. But while running the packaged app Cannot find module X is thrown.
The folder ./out/app/resources/app/node_modules is empty.
Also the package.json ./out/app/resources/app/package.json looks as follows.
"name": "my-app",
"productName": "my-app",
"version": "1.0.0",
"description": "My Electron application description",
"main": ".webpack/main",
"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": "",
"email": ""
},
"license": "MIT",
"config": {},
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"peerDependencies": {}
}
None of the dependencies in the source package.json made it to the packaged app.
Try this
cd "my-app"
:: install dependency into your node_modules and update your package.json
npm install your-dependency --save-prod
npm run make

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

Resources