Hi I have an Electron app that's running Puppeteer (To be specific it is puppeteer-cluster). I want to be able to package this app into a .exe that I can distribute with.
One requirement though is that I have to be able to pack it with --asar.
Here's some stuff I tried but failed:
I tried setting the executable path :
let ChromiumPath = path.join(__dirname, "..", "..", "..",".local-chromium", "win64-809590", "chrome-win","chrome.exe");
const cluster = await Cluster.launch({
puppeteer,
concurrency: Cluster.CONCURRENCY_BROWSER,
maxConcurrency: arg.length,
timeout: 340000,
puppeteerOptions: {
args: browserArgs,
headless: false,
ignoreHTTPSErrors: true,
executablePath : ChromiumPath
},
perBrowserOptions: perBrowserOptions,
});
I tried specifying the unpack directory in package.json
"config": {
"forge": {
"packagerConfig": {
"asar": {
"unpack": "**/node_modules/puppeteer/.local-chromium/**/*"
}
}.....
Here's how i package my app:
electron-packager . --asar
And if needed, here's my package.json:
{
"name": "testBrowsers",
"productName": "testBrowsers",
"version": "1.0.0",
"description": "IDk",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-packager ./ testBrowsers --platform=win32 --arch=x64 --icon=./tool.ico --out=./dist --electron-version=10.1.4 --overwrite",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": "Otter",
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {
"asar": {
"unpack": "**/node_modules/puppeteer/.local-chromium/**/*"
}
},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"name": "testBrowsers"
}
},
{
"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",
"proxy-chain": "^0.4.5",
"puppeteer": "^5.4.1",
"puppeteer-cluster": "^0.22.0",
"puppeteer-extra": "^3.1.15",
"puppeteer-extra-plugin-stealth": "^2.6.5",
"puppeteer-page-proxy": "^1.2.8",
"taskkill": "^3.1.0"
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.54",
"#electron-forge/maker-deb": "^6.0.0-beta.54",
"#electron-forge/maker-rpm": "^6.0.0-beta.54",
"#electron-forge/maker-squirrel": "^6.0.0-beta.54",
"#electron-forge/maker-zip": "^6.0.0-beta.54",
"electron": "10.1.4"
}
}
Thanks I really hope someone can help me out with this issue! :)
You will probably need to package chromium separately from your application. At least that's what you would do when trying to package a node application using something like pkg.
You can load chromium in puppeteer from a custom install path when launching a browser instance. So in code you will need to specify that path and make sure that your packaged app has the ability to read that path.
Your distribution file (probably an archive) will then have the chromium build that puppeteer needs separate from the actual app exe
have a look at a similar discussion here
https://github.com/vercel/pkg/issues/204
Related
I'm trying to publish an extension by vsce, I logged in with the user access token,
after the build its create a file named 'NadavShaked.my-first-extension v1.0.968.vsix'
I'm trying to publish the extension to the marketplace by this command 'vsce publish' and received this error:
this is the guide I used
https://code.visualstudio.com/api/working-with-extensions/publishing-extension
this is my azure-devops-extension.json file:
{
"manifestVersion": 1,
"id": "my-first-extension",
"publisher": "NadavShaked",
"version": "1.0.968",
"name": "my-first-extension",
"description": "Azure DevOps Extension",
"categories": [
"Azure Repos",
"Azure Boards",
"Azure Pipelines",
"Azure Test Plans",
"Azure Artifacts"
],
"targets": [ {
"id": "Microsoft.VisualStudio.Services"
} ],
"icons": {
"default": "logo.png"
},
"content": {
"details": {
"path": "overview.md"
}
},
"files": [ {
"path": "dist",
"addressable": true
} ]
}
this is my package.json file:
{
"id": "my-first-extension",
"name": "my-first-extension",
"publisher": "NadavShaked",
"version": "1.0.968",
"description": "Azure DevOps Extension",
"keywords": [
"extensions",
"Azure DevOps",
"Visual Studio Team Services"
],
"engines": {
"vscode": "^1.8.0"
},
"license": "MIT",
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"clean": "rimraf ./dist",
"compile": "npm run clean && npm run test && webpack --mode production",
"compile:dev": "npm run clean && npm run test && webpack --mode development",
"build": "npm run compile",
"build:dev": "npm run compile:dev && npm run postbuild",
"postbuild": "npm run package-extension -- --rev-version",
"package-extension": "tfx extension create --manifest-globs azure-devops-extension.json src/Samples/**/*.json",
"publish-extension": "tfx extension publish --manifest-globs azure-devops-extension.json src/Samples/**/*.json",
"test": "set TEST_REPORT_FILENAME=test-results.xml && jest --verbose"
},
"dependencies": {
"#fluentui/react": "^8.36.3",
"azure-devops-extension-api": "~1.157.0",
"azure-devops-extension-sdk": "~2.0.11",
"azure-devops-ui": "~2.164.0",
"react": "~16.13.1",
"react-dom": "~16.13.1"
},
"devDependencies": {
"#testing-library/jest-dom": "^5.11.0",
"#testing-library/react": "^10.4.4",
"#types/jest": "^26.0.3",
"#types/react": "~16.8.2",
"#types/react-dom": "~16.8.0",
"copy-webpack-plugin": "^7.0.0",
"base64-inline-loader": "~1.1.1",
"css-loader": "~1.0.0",
"jest": "^26.1.0",
"jest-junit-reporter": "^1.1.0",
"node-sass": "^5.0.0",
"rimraf": "~2.6.2",
"sass-loader": "~10.0.5",
"style-loader": "~0.23.1",
"tfx-cli": "^0.6.3",
"ts-jest": "^26.1.1",
"ts-loader": "~5.2.2",
"typescript": "^3.9.6",
"webpack": "^5.23.0",
"webpack-cli": "^4.5.0"
},
"jest": {
"transform": {
"^.+\\.(js|ts|tsx|jsx)$": "ts-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!(react-native|azure-devops-ui|azure-devops-extension-sdk)/)"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js",
"\\.(css|less|scss)$": "<rootDir>/src/__mocks__/styleMock.js"
},
"preset": "ts-jest/presets/js-with-babel",
"testResultsProcessor": "./node_modules/jest-junit-reporter",
"collectCoverage": true,
"coverageReporters": [
"json",
"html",
"cobertura"
],
"globals": {
"ts-jest": {
"tsconfig": "tsconfig.test.json"
}
}
}
}
I upload the project to git my repo:
https://github.com/NadavShaked/vstsExtension/tree/master/vsts%20extension
this is the extension by run: 'vsce package'
https://easyupload.io/skwmep
this is the extension by run: 'npm run build'
https://easyupload.io/kzopux
I prefer to publish the second extension (npm run build command)
vsce is not the right command to publish to Azure devops.
In my package.json, I used npm run publish-extension or better npm run package-extension and published it by hand.
Asking again 'cause I havent had any luck finding this information. Does anyone know where I can find the documentation or steps to package my Electron app for Windows on a Mac running OS Catalina(10.15)? I've successfully published for DMG and and .zip for Mac OS. Using electron-forge currently.
I read the Electron documentation to use wine or mono and I installed both, but I'm not sure what to do after that. I tried running the electron-packager after installing both but it still ignores the squirrel-maker for Windows. Tried running electron-make and publish, all ignore the squirrel-maker.
I got an error once that I needed to use 'electron-compile' but when I installed it and tried using it, it kept throwing an error on my source code when it would come across a dot operator for arrays or objects? Ex:
let object = {Name:"Something"}
let object2 = {Age:20}
let newObject = {
...object,
...object2
}
Would throw an error when trying to use the 'electron-compile' framework.
Really trying to avoid flipping back and forth between Windows and Mac on my mac and having to install electron on both platforms.
package.json file:
"name": "MyApp",
"productName": "My Fantastic App",
"version": "1.1.4",
"description": "The worlds most boring app.",
"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\"",
"dist": "build",
"build": "electron-builder build --dir"
},
"keywords": [],
"author": "sychordCoder",
"license": "MIT",
"config": {
"forge": "./custom-not.js"
},
"dependencies": {
"dotenv": "^9.0.2",
"electron-dl": "^3.2.1",
"electron-is-dev": "^2.0.0",
"electron-log": "^4.3.5",
"electron-squirrel-startup": "^1.0.0",
"electron-updater": "^4.3.9",
"firebase": "^8.6.2",
"jquery": "^3.6.0",
"pug": "^3.0.2"
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.54",
"#electron-forge/maker-deb": "^6.0.0-beta.54",
"#electron-forge/maker-dmg": "^6.0.0-beta.54",
"#electron-forge/maker-rpm": "^6.0.0-beta.54",
"#electron-forge/maker-squirrel": "^6.0.0-beta.54",
"#electron-forge/maker-zip": "^6.0.0-beta.54",
"#electron-forge/publisher-github": "^6.0.0-beta.54",
"electron": "^12.0.0",
"uglify-js": "^3.13.7"
}
}
This is my config js file:
module.exports = {
packagerConfig: {
name: 'MyApp',
executableName: 'MyApp',
asar: true,
icon: 'src/images/icon128#2x',
ignore: ["file1source.js","file2source.js"],
appBundleId: 'MyAppId',
osxSign: {
identity: 'Developer ID Application: John Smith(90210)',
hardenedRuntime: true,
'gatekeeper-assess': false,
entitlements: 'static/entitlements.plist',
'entitlements-inherit': 'static/entitlements.plist',
'signature-flags': 'library'
},
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD
}
},
makers: [
{
name: '#electron-forge/maker-squirrel',
platforms: [
"win32"
],
config: {
name: 'MyApp',
description: 'The worlds most boring app.',
version: '1.1.4'
}
},
{
name: '#electron-forge/maker-zip',
platforms: [
'darwin'
]
},
{
name: '#electron-forge/maker-deb',
config: {}
},
{
name: '#electron-forge/maker-rpm',
config: {}
},
{
name: '#electron-forge/maker-dmg',
config: {
overwrite:true,
icon: 'src/images/icon128#2x.icns'
}
}
],
publishers: [
{
name: '#electron-forge/publisher-github',
config: {
repository: {
owner: 'githubOwner',
name: 'gitHubReleases'
},
prerelease: false,
releaseType: "release",
authToken: process.env.GH_TOKEN
}
}
]
}
Any help is greatly appreciated.
Thank you,
you should open the wine terminal to run command of build electron.
I wanted to use electron-builder in my electron-forge (webpack-template and React) app, because of the more packaging options
electron-forge app was created with
create electron-app test --template=webpack
This is my package.json
"name": "vocascan",
"productName": "vocascan",
"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\"",
"build": "electron-forge start && electron-builder --linux"
},
"keywords": [],
"build": {
"productName": "Vocascan",
"files": [
],
"linux": {
"target": [
"AppImage"
],
"category": "Development"
}
},
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {},
"plugins": [
[
"#electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "./src/index.html",
"js": "./src/renderer.jsx",
"name": "main_window"
}
]
}
}
]
]
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.54",
"#electron-forge/maker-deb": "^6.0.0-beta.54",
"#electron-forge/maker-rpm": "^6.0.0-beta.54",
"#electron-forge/maker-squirrel": "^6.0.0-beta.54",
"#electron-forge/maker-zip": "^6.0.0-beta.54",
"#electron-forge/plugin-webpack": "6.0.0-beta.54",
"#marshallofsound/webpack-asset-relocator-loader": "^0.5.0",
"css-loader": "^4.2.1",
"electron": "10.1.5",
"node-loader": "^1.0.1",
"style-loader": "^1.2.1",
"electron-builder": "^22.9.1"
},
"dependencies": {
"#babel/core": "^7.12.3",
"#babel/preset-env": "^7.12.1",
"#babel/preset-react": "^7.12.5",
"babel-loader": "^8.1.0",
"electron-squirrel-startup": "^1.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1"
}
As you can see I added
"build": "electron-forge start && electron-builder --linux"
and
"build": {
"productName": "Vocascan",
"files": [
],
"linux": {
"target": [
"AppImage"
],
"category": "Development"
}
},
in order to make electron-builder available
the build runs just fine, but when I start the app none of my components gets shown
If someone needs the browser window code
const createWindow = () => {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
});
// and load the index.html of the app.
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
// Open the DevTools.
mainWindow.webContents.openDevTools();
};
and this is my folder structure
This template is NOT working with electron-builder.
Because this template was designed to work with the electron-forge make command. electron-builder can't work with it because it's using webpack dev server and not building a static build.
The template I linked is working with electron-builder because it's making a static build of react, the react components and the node modules you using and electron-builder can work with it.
I recommend this template: https://github.com/Levminer/create-electron-react-app
I have an electron application with main process as follows:
const {app, BrowserWindow, Menu, dialog} = require('electron');
const path = require('path')
let logConfig = require('./js/loggConfig.js');
....
This executes perfectly when run directly from terminal.
But when I package this project using electron-builder, and install it on another machine (Windows 10), I get the following error while launching the app:
Error: Cannot find module '.js/loggConfig.js'
How do I resolve this?
Here is how my package.json looks like:
{
"name": "ABCD",
"version": "0.0.1",
"description": "...",
"author": "abcd <abcd#gmail.com>",
"homepage": "http://www.abcd.com",
"main": "main_electron.js",
"scripts": {
"postinstall": "install-app-deps",
"start": "electron .",
"dist": "build"
},
"build": {
"appId": "yourappid",
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"deb"
],
"category": "Video"
},
"win": {
"target": "NSIS",
"icon": "build/icon.ico",
"extraResources": [
]
}
},
"dependencies": {
"electron-context-menu": "^0.9.1",
"electron-log": "^2.2.13",
"fs": "0.0.1-security",
"mkdirp": "^0.5.1",
"path": "^0.12.7",
"uuid": "^3.1.0",
"xmlbuilder": "^9.0.4",
"zip-folder": "^1.0.0"
},
"devDependencies": {
"electron": "^1.7.9",
"electron-builder": "^19.49.0"
}
}
I solved the issue changing the build configuration.
Setting asar to false.
Setting asarUnpack to export all the asar content with "**/*".
"build": {
"appId": "app.node.electron",
"productName": "app electron",
"asar":false,
"asarUnpack":[
"**/*"
],
"directories": {
"output": "release"
},
"win": {
"publisherName": "app electron",
"icon": "icon.png",
"target": [
"nsis"
]
},
},
I'm having an issue when building my web application using Brunch. My application depends on a module I've created and uploaded to NPM, and whenever I build it, I get:
DEPS_RESOLVE_FAILED of node_modules/rd-vue-bootstrap/dist/rd-vue-bootstrap.js failed.
Could not load module './bs-button-group.vue' from '/Users/rjuliani/dev/production-manager-ui/node_modules/rd-vue-bootstrap/dist'.
Make sure the file actually exists
The module itself builds just fine, however when I use it from my test web application and build it (the web application) it throw me the above error.
The relevant parts of my package.json file for the module are:
"main": "dist/rd-vue-bootstrap.js",
"files": [
"dist/rd-vue-bootstrap.js",
"dist/rd-vue-bootstrap.js.map",
"dist/rd-vue-bootstrap.min.js",
"src"
],
brunch-config.js
module.exports = {
files: {
javascripts: {
joinTo: 'app.js'
},
templates: {
joinTo: 'app.js'
}
},
plugins: {
babel: {
},
assetsmanager: {
copyTo: {
'vendor': ['node_modules/bootstrap', 'node_modules/jquery', 'node_modules/rd-vue-bootstrap']
},
minTimeSpanSeconds: 10 // assets won't be copied more frequent than once per X seconds.npm
}
}
};
initialize.js (main file for my web application)
import Vue from 'vue';
import RdVueBootstrap from 'rd-vue-bootstrap';
Vue.use(RdVueBootstrap);
Finally, package.json for my test web application
{
"name": "production-manager-ui",
"description": "Simple UI for the production-manager API project",
"version": "0.0.1",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/radical-dreamers/production-manager-ui.git"
},
"scripts": {
"watch": "brunch watch --server",
"build": "brunch build --production"
},
"author": {
"url": "http://www.codelightsoftware.com",
"name": "Rodrigo Juliani",
"email": "srodriki#gmail.com"
},
"keywords": [
"vue",
"brunch"
],
"dependencies": {
"bootstrap": "^3.3.7",
"jquery": "^3.1.0",
"rd-vue-bootstrap": "0.0.6",
"vue": "^1.0.26",
"vue-router": "^0.7.13"
},
"devDependencies": {
"assetsmanager-brunch": "^1.8.1",
"auto-reload-brunch": "^2.7.1",
"babel-brunch": "^6.0.6",
"brunch": "^2.8.2",
"css-brunch": "^2.6.1",
"javascript-brunch": "^2.0.0",
"vue-brunch": "^1.1.2",
"vue-devtools": "^2.0.4"
}
}
Any ideas how to fix this? I've tried many things and nothing seems to be working as of right now :(
Thanks!