SamuelScheit / puppeteer-stream

A Library for puppeteer to retrieve audio and/or video streams
MIT License
333 stars 105 forks source link

Problems with the examples! #89

Closed ZakariaMrad closed 1 year ago

ZakariaMrad commented 1 year ago

Hello! I'm trying to include your package in a project of mine, (recording an HTML page), but I have problems incorporating it. I'm testing your examples and having trouble making them work. I either get the error : Error: An 'executablePath' or 'channel' must be specified for 'puppeteer-core' at assert (Project\Testing Phase\puppeteer-stream\node_modules\puppeteer-core\lib\cjs\puppeteer\util\assert.js:28:15), or I'm getting an empty output (there isn't any binary value in test.webm).

I've tried your example with an ts file and a js file and my npm packages are puppeteer, puppeteer-core and puppeteer-stream. I've even tried before installing puppeteer. The code is a ctrl-c ctrl-v from examples/fils.js and this is my package.json: { "name": "puppeteer-stream", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "puppeteer": "^19.6.2", "puppeteer-core": "^19.6.2", "puppeteer-stream": "^2.1.4" } }

Thank you very much!

SamuelScheit commented 1 year ago

you need to use the puppeteer package instead of puppeteer-core

genki commented 1 year ago

@SamuelScheit Seemed the package.json does that https://github.com/SamuelScheit/puppeteer-stream/blob/ab31da559cd22513944698e79b45205fe0cc5e55/package.json#L24

alpharder commented 1 year ago

Same here, but I'm not using puppeteer-core in any way:

/Users/alpharder/dev/soflyy/tutorials/node_modules/puppeteer-stream/node_modules/puppeteer-core/lib/cjs/puppeteer/util/assert.js:28
        throw new Error(message);
              ^

Error: An `executablePath` or `channel` must be specified for `puppeteer-core`
    at assert (/Users/alpharder/dev/soflyy/tutorials/node_modules/puppeteer-stream/node_modules/puppeteer-core/lib/cjs/puppeteer/util/assert.js:28:15)
    at ChromeLauncher.launch (/Users/alpharder/dev/soflyy/tutorials/node_modules/puppeteer-stream/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:92:36)

Node.js v19.7.0
SamuelScheit commented 1 year ago

@alpharder I found the issue, puppeteer-stream uses puppeteer-core for the launch method and it is missing the executable path. If you are using puppeteer you can get the path to chromium with the puppeteer.executablePath() function. e.g.


const puppeteer = require("puppeteer")
const { launch, getStream } = require("puppeteer-stream")

async function test() {
    const browser = await launch({
            executablePath: puppeteer.executablePath()
        // ...
    });
// ...
}

test();