GithubHelp home page GithubHelp logo

Comments (1)

AlexJeffcott avatar AlexJeffcott commented on May 17, 2024

This is likely because the pipe option does not work in Deno which makes the compatibility claim in https://deno.com/blog/v1.35 a little confusing.

Assuming you have “installed” a browser with deno run -q --no-lock -A --unstable --no-check --reload npm:puppeteer/install.mjs, the following code works with deno run -A index.mjs (it does have a “Warning: Not implemented: ClientRequest.options.createConnection”, though).

// index.mjs
import puppeteer from 'npm:puppeteer'

(async () => {
  const browser = await puppeteer.launch({
    headless: 'new',
    pipe: false
  });
  const page = await browser.newPage();
  await page.goto('https://developer.chrome.com/');
  await page.setViewport({width: 1920, height: 1080});
  await page.screenshot({path: './test.jpg'})
  await browser.close();
  Deno.exit(1)
})();

But with pipe: true it breaks with the same deno run -A index.mjs command.
Here is the output: error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on').

You can find the same issue with regards to Playwright support. See denoland/deno#16899 (comment) and microsoft/playwright#3146 (comment)

// index.mjs
import puppeteer from 'npm:puppeteer'

(async () => {
  const browser = await puppeteer.launch({
    headless: 'new',
    pipe: true
  });
  const page = await browser.newPage();
  await page.goto('https://developer.chrome.com/');
  await page.setViewport({width: 1920, height: 1080});
  await page.screenshot({path: './test.jpg'})
  await browser.close();
  Deno.exit(1)
})();

Here is the same in Node (assuming that you have installed Puppeteer with npm i puppeteer which works just fine with the pipe option by running node index.mjs.

// index.mjs
import puppeteer from 'puppeteer'

(async () => {
  const browser = await puppeteer.launch({
      headless: 'new',
      pipe: true
  });
  const page = await browser.newPage();
  
  await page.goto('https://developer.chrome.com/');
  await page.setViewport({width: 1920, height: 1080});
  await page.screenshot({path: './test.jpg'})
  await browser.close();
})();

from deno-puppeteer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.