My project is a desktop Electron application that scrapes a website on click. Simple.
My project works fine locally (of course), but when I go and run npm run package-win and create my Windows production application, I believe the error appears when puppeteer tries to start the browser.
I only get this when build for windows. building on my mac it works and no errors...
Chromium revision is not downloaded. Run "npm install" or "yarn install" at Launcher.launch
I tried deleting the package.lock, node_modules folder, and of course running npm install as suggested. I think it has something to do with the versioning? Here is my package.json file:
{
"name": "my-project",
"version": "1.0.0",
"description": "My project description.",
"main": "main.js",
"scripts": {
"start": "electron .",
"package-win": "electron-packager . my-project --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=\"My Project\""
},
"license": "CC0-1.0",
"devDependencies": {
"electron": "^2.0.12",
"electron-packager": "^12.2.0"
},
"dependencies": {
"electron-json-storage": "^4.1.4",
"nodemailer": "^4.6.7",
"puppeteer": "^1.8.0"
}
}
I can tell my try catch is failing as the error message is from the catch so something inside this block is failing but only in the production build:
async scrape(url) {
try {
// Launch & Setup browser
this.browser = await puppeteer.launch({
args: ["--no-sandbox"],
headless: true
});
this.page = await this.browser.newPage();
await this.page.setViewport({
width: 1920,
height: 926
});
this.page.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36');
await this.page.goto(url);
await this.page.waitForSelector('ul.rows');
// Get all the listings on the page
this.listings_array = await this.get_DOM_elements_from_page();
console.log(this.listings_array);
} catch (err) {
console.log('SOMETHING WENT WRONG', err);
}
}
This function is inside of a class. That's why the reference to this. I store the browser, page, and other things on the instance of a scraper.