Back

Playwright Node.js

  • 0
  • Self Hosted
  • Functions
ZachHandley
21 Feb, 2024, 05:40

So, wondering how or if I can get Playwright working on Node.js with Functions, I've been trying but getting no luck getting Playwright to see the Chromium I have installed using a Puppeteer trick Steven taught me. Getting this error:

TypeScript
Failed to launch browser. Please check the following:
- Try installing the required dependencies by running `npx playwright install --with-deps` (https://playwright.dev/docs/browsers).

The original error is available in the `cause` property. Below is the error received when trying to launch a browser:

browserType.launchPersistentContext: Executable doesn't exist at /root/.cache/ms-playwright/chromium-1097/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers:              ║
║                                                                         ║
║     npx playwright install                                              ║
║                                                                         ║
║ <3 Playwright Team                                                      ║
╚═════════════════════════════════════════════════════════════════════════╝
    at async PlaywrightPlugin._launch (/usr/local/server/src/function/node_modules/@crawlee/browser-pool/playwright/playwright-plugin.js:105:40)
    at async BrowserPool._launchBrowser (/usr/local/server/src/function/node_modules/@crawlee/browser-pool/browser-pool.js:465:29)
    at /usr/local/server/async /usr/local/server/src/function/node_modules/@crawlee/browser-pool/browser-pool.js:274:37
Error thrown at:

    at PlaywrightPlugin._throwAugmentedLaunchError (/usr/local/server/src/function/node_modules/@crawlee/browser-pool/abstract-classes/browser-plugin.js:145:15)
    at PlaywrightPlugin._throwOnFailedLaunch (/usr/local/server/src/function/node_modules/@crawlee/browser-pool/playwright/playwright-plugin.js:161:14)
    at /usr/local/server/src/function/node_modules/@crawlee/browser-pool/playwright/playwright-plugin.js:106:33
    at async PlaywrightPlugin._launch (/usr/local/server/src/function/node_modules/@crawlee/browser-pool/playwright/playwright-plugin.js:105:40)
    at async BrowserPool._launchBrowser (/usr/local/server/src/function/node_modules/@crawlee/browser-pool/browser-pool.js:465:29)
    at async /usr/local/server/src/function/node_modules/@crawlee/browser-pool/browser-pool.js:274:37
TL;DR
Developers are encountering issues getting Playwright to work on Node.js with Functions. They are facing errors related to browser launch failure and dependency installation. The suggested solution is to run `npx playwright install` to download new browsers.
ZachHandley
21 Feb, 2024, 05:41
TypeScript
execSync('apk add /usr/local/server/src/function/*.apk');
const crawler = new PlaywrightCrawler(
    {
      // proxyConfiguration: new ProxyConfiguration({ proxyUrls: ['...'] }),
      requestHandler: router,
      // Comment this option to scrape the full website.
      maxRequestsPerCrawl: maxLinks,
    },
    new Configuration({
      chromeExecutablePath: '/usr/bin/chromium-browser',
    })
  );
Steven
21 Feb, 2024, 05:44

Seems like it's not picking up that configuration because the paths don't match up 🧐

ZachHandley
21 Feb, 2024, 05:45

Yeah I tried running npx install playwright --with-deps in the execSync and that did not work either

ZachHandley
21 Feb, 2024, 05:45

clearly it's clearing the cache, I could move the installed browsers to the folder after maybe

ZachHandley
21 Feb, 2024, 05:46

also for the record obvs not making a malicious crawler, making it for documentation for the discord bot I'm building to trial out

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more