@Cebastion
Front-end developer

Как решить данную проблему "Error: Failed to launch the browser process! undefined"?

Вот код

import puppeteer from 'puppeteer';

(async () => {
  // Launch the browser and open a new blank page
  const browser = await puppeteer.launch({
    headless: false,
    executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe'
  });
  const page = await browser.newPage();

  // Navigate the page to a URL
  await page.goto('https://developer.chrome.com/');

  // Set screen size
  await page.setViewport({width: 1080, height: 1024});

  // Type into search box
  await page.type('.search-box__input', 'automate beyond recorder');

  // Wait and click on first result
  const searchResultSelector = '.search-box__link';
  await page.waitForSelector(searchResultSelector);
  await page.click(searchResultSelector);

  // Locate the full title with a unique string
  const textSelector = await page.waitForSelector(
    'text/Customize and automate'
  );
  const fullTitle = await textSelector?.evaluate(el => el.textContent);

  // Print the full title
  console.log('The title of this blog post is "%s".', fullTitle);

  await browser.close();
})();


Я хочу сделать бота на JS. Но не могу понять, почему он не работает. Если сделать вот так:

const browser = await puppeteer.launch({ headless: false, });


То я получаю эту ошибку:
Error: Failed to launch the browser process! undefined
[1219/110148.871:ERROR:main_dll_loader_win.cc(112)] Failed to load Chrome DLL from C:\Users\APREL\.cache\puppeteer\chrome\win64-119.0.6045.105\chrome-win64\chrome.dll: ?? ??????? ????????? ?????????. (0x7F)


А если я добавлю в launch executablePath:

const browser = await puppeteer.launch({ headless: false, executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' });


То код работает, но он просто запускает хром и нечего не делает.
Что делать? Как решить проблему?


Забыл сказать! При установлении puppeteer он создает папку .cache в котором есть хром, но он жалуется
Error: Failed to launch the browser process! undefined
[1219/110148.871:ERROR:main_dll_loader_win.cc(112)] Failed to load Chrome DLL from C:\Users\APREL\.cache\puppeteer\chrome\win64-119.0.6045.105\chrome-win64\chrome.dll: ?? ??????? ????????? ?????????. (0x7F)

а если добавляю C:/Program Files/Google/Chrome/Application/chrome.exe, то он просто открывает хром
  • Вопрос задан
  • 100 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы