question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: '_projectRoot is undefined. Unable to create a BrowserFetcher.' ( v18.0.4 )

See original GitHub issue

Bug description

Steps to reproduce the problem:

const puppeteer = require('puppeteer-core');
const browserFetcher = puppeteer.createBrowserFetcher({
        path: 'to-my-path'
    });

throw a error: node_modules\puppeteer-core\lib\cjs\puppeteer\node\Puppeteer.js:206 throw new Error(‘_projectRoot is undefined. Unable to create a BrowserFetcher.’); ^ Error: _projectRoot is undefined. Unable to create a BrowserFetcher.

API createBrowserFetcher broken, it’s works on previous version

Puppeteer version

v18.0.4

Node.js version

v16.17.0

npm version

8.18.0

What operating system are you seeing the problem on?

Windows

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
cenfuncommented, Sep 30, 2022

thanks @jrandolf Here’s some background Why puppeteer-core, because we don’t want to download chromium when running “npm install”, and the chromium size is very large (400M unzipped) Why createBrowserFetcher, because we want to download chromium to a different directory like user directory but not node_modules, so it can be cached So puppeteer-core + createBrowserFetcher can solve these usage scenarios very well, but it is broken now However we can directly call BrowserFetcher to solve it

//fix '_projectRoot is undefined. Unable to create a BrowserFetcher.'
const { BrowserFetcher } = require('puppeteer-core/lib/cjs/puppeteer/node/BrowserFetcher.js');
const createBrowserFetcher = (options) => {
    return new BrowserFetcher('', options);
};
// instead of puppeteer.createBrowserFetcher()

It’s just that BrowserFetcher is not a public API, we still hope to fix the public API createBrowserFetcher, thanks again.

1reaction
jrandolfcommented, Sep 29, 2022

Could you try puppeteer instead of puppeteer-core?

[EDIT]: Scratch that. I assume you are looking to just have the launcher as a separate API. There are some discussions regarding this. If all goes well, it should be come a separate API this quarter. We will see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

0 - Stack Overflow
The issue seems to be that you are using the puppeteer NPM package, based on the route you've shared in your error stack:...
Read more >
Class BrowserFetcher - Puppeteer Sharp
BrowserFetcher operates on revision strings that specify a precise version of Chromium, e.g. 533271. Revision strings can be obtained from omahaproxy.appspot.
Read more >
try - Mercurial - Mozilla
_projectRoot) { + throw new Error( + '_projectRoot is undefined. Unable to create a BrowserFetcher.' + ); + } const browserFetcher = new...
Read more >
puppeteer: Versions | Openbase
use ~/.cache/puppeteer for browser downloads (#9095); deprecate createBrowserFetcher in favor of BrowserFetcher (#9079); refactor custom query handler API ...
Read more >
[Bug]: '_projectRoot is undefined. Unable to create a BrowserFetcher ...
( v18.0.4 ) ... const puppeteer = require('puppeteer-core'); const browserFetcher = puppeteer. ... throw new Error('_projectRoot is undefined. Unable to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found