Electron packager has packaged my app.But it doesn't have all the node modules as present in my app before packaging. I am forced to manually run npm install inside my packaged folder.
So, the app is not able to perform as expected.
I tried inside package.json
"build": {
"files": [
"/node_modules/**",
"package.json"
]
}
It looks like you are using your package.json wrong way.
Only "dependencies" will be included to the build if you put some package to "devDependencies" it will be excluded from the build.
use no-prune in build using electron packager and place all the modules inside devDependencies and then build the app.
Related
We have a service inside a monorepo project, we want to install only that service.
We are able to install the node_modules inside that service folde (rather than at the root folder) when adding the following to package.json:
"installConfig": {
"hoistingLimits": "workspaces"
}
That's great, but some of the dependencies are links to other local packages in the repo.
Is there a way to force yarn to 'deep copy' the dependencies in the node_modules folder?
I'm using electron-builder to package my application. I have a dist/ folder where all resources are. main.js in root folder does not need any transpiling and includes main process code. This works well in development mode when launching using electron command.
I have electron-builder set up using package.json configuration:
[...]
"main": "./main.js",
"build": {
"appId": "com.electron.mycompany.myapp",
"productName": "myapp",
"linux": {
"target": "deb"
},
"files": [
"./dist",
"./main.js"
]
},
[...]
I'm launching electron-builder like this: electron-builder -ml build. Macos build packages fine and I'm able to launch the application. However Linux build fails. I'm building Linux package on macos Catalina. It gives me error stack trace:
rebuilding native dependencies dependencies=leveldown#5.6.0 platform=linux arch=x64
⨯ Unknown target: build stackTrace=
Error: Unknown target: build
at createCommonTarget (/Users/username/Projects/myappnode_modules/app-builder-lib/src/targets/targetFactory.ts:90:11)
at /Users/username/Projects/myapp/node_modules/app-builder-lib/src/linuxPackager.ts:65:18
at mapper (/Users/username/Projects/myapp/node_modules/app-builder-lib/src/targets/targetFactory.ts:57:16)
at LinuxPackager.createTargets (/Users/username/Projects/myapp/node_modules/app-builder-lib/src/linuxPackager.ts:63:7)
at createTargets (/Users/username/Projects/myapp/node_modules/app-builder-lib/src/targets/targetFactory.ts:64:12)
at Packager.doBuild (/Users/username/Projects/myapp/node_modules/app-builder-lib/src/packager.ts:442:28)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at executeFinally (/Users/username/Projects/myapp/node_modules/builder-util/src/promise.ts:12:14)
at Packager._build (/Users/username/Projects/myapp/node_modules/app-builder-lib/src/packager.ts:373:31)
at Packager.build (/Users/username/Projects/myapp/node_modules/app-builder-lib/src/packager.ts:337:12)
at executeFinally (/Users/username/Projects/myapp/node_modules/builder-util/src/promise.ts:12:14)
• building embedded block map file=dist/IJP Visualization Tool-1.0.0-alpha.1-mac.zip
I am not using any code signing (nor do I wish to). Is something misconfigured? It seems to be it but not sure what the problem is exactly.
As per the electron-builder CLI documentation, all platform switches accept a "target list", which in essence is what you configure in your package.json with your different platform entries (build.<platform>.target, e.g. build.linux.target).
However, by using these target lists, you can specify which targets you want to build and exclude all others. Since Linux' switch is the last in the switch list -ml, Electron Builder interprets this as though you want to pass it a target list. This does not apply to the macOS build step because then you would have to use -m <targets> -l <targets>, -ml <targets> apparently only applies to Linux.
Thus, by appending build to the command line, you tell Electron Builder to compile all configured targets for macOS but only build the Linux target called build. Since there is no such target, Electron Builder crashes. Removing build from your command will do the trick.
I have been using electron to make desktop application for a while now but still can't figure out how it can be packaged for all the available linux distributions
For ALL linux distributions I have no idea. The way I make mine Linux Electron projects is just
npm install --save-dev electron-builder
add this to the root of my package.json
"build": {
"appId": "com.myname.appname",
"asar": true,
"mac": {
"category": "public.app-category.developer-tools"
}
},
I make a build folder in the root and put
icon.icns
icon.ico
which I built from this site
and then
./node_modules/.bin/electron-builder
it puts an .AppImage file in dist
more instructions here
I have successfully built an Electron app. Now I'm trying to change the icon of the .exe that is generated by electron-packager. However, the .exe gets the default Electron icon, not my own icon (see screenshot).
The command I run: npm run build
The corresponding script in package.json:
"build": "electron-packager --out winx64 --overwrite --platform win32 --appname clientlmcenter . --icon my_logo.ico"
The file my_logo.ico is present in the root directory.
You have to put icon argument like this
--icon=./my_logo.ico
Also make sure the logo is in the current directory where you execute npm run build
Another solution that I found is adding the icon in the packaje.json taking into account that the icon is in the root.
{
"name": "nameAplication",
"version": "1.0.0",
"icon": "favicon.ico",
}
and when creating the executable add this command
electron-packager . --platform=win32 --arch=x64 --icon=favicon.ico
I have problem with project(https://github.com/Gordienko-RU/plant-log), there are angular bundle in dist folder and electron main file into electron folder, but after packaging with electron-builder, application doesn't run.
I guess there are some problems with my config in to package.json
Ok, I had a similar issue with electron-packager. I tried your package.json and did a "npm install". To me it looks like that your build does include native addons (*.node).
In electron-packager the solution was to add the asar unpack option. You are using electron-builder. Therefore you should look at this thread: https://github.com/electron-userland/electron-builder/issues/390 . Maybe you need to specify the modules by hand, like:
"asar": true,
"asarUnpack": [
"../node_modules/uws"
]