D
D
Denis Shcherbina2021-10-09 20:46:22
Node.js
Denis Shcherbina, 2021-10-09 20:46:22

Why is the compiled application in nwjs not seen by puppeteer?

My application is a bot written in node js + puppeteer
Now I have made a control interface in nwjs (windows). All this works fine during testing. After compiling, my application starts, I see the interface, but when the bot starts (browser launch), an error occurs - it does not see chromium:

Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (901912).

I tried to set the path to the browser, it did not help. For example:
const puppeteer = require('puppeteer');
// ========================== //
browser = await puppeteer.launch({
      executablePath: '.\\node_modules\\puppeteer\\.local-chromium\\win64-901912\\chrome-win\\chrome.exe',
      headless: true,
      args: [
        '--no-sandbox'
      ]
    });

What should I do to make my compiled code work with puppeteer?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Shcherbina, 2021-11-08
@Denis_maker

The solution is this: I moved the folder with the browser to another location:
from "C:\ . . . \node_modules\puppeteer\.local-chromium\win64-818858\chrome-win"
here: "C:\chrome-win"
And in I write code:

browser = await puppeteer.launch({
      executablePath: 'C:\chrome-win',
      headless: true,
      args: [
        '--no-sandbox'
      ]
   });

In this case, the compiled application sees the browser and works fine with it. After this misunderstanding, I tried electron - everything worked there by default and everything feels faster somehow. Now I recommend it:
https://www.electronjs.org/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question