Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: __dirname points to root #7932

Closed
codydaig opened this issue Jan 26, 2022 · 1 comment
Closed

[Bug]: __dirname points to root #7932

codydaig opened this issue Jan 26, 2022 · 1 comment
Labels

Comments

@codydaig
Copy link

Bug description

Steps to reproduce the problem:

  1. In a project that uses webpack and typescript, depending on configuration of other node/webpack items, __dirname points to /. This results in a TypeError tracing back to the Browser Launch.

Further investigations show that initializePuppeteerNode isn't setting puppeteerRootDirectory.

The fix for this is to fall back to process.cwd() when pkgDir.sync(__dirname) comes back undefined.

Puppeteer version

13.1.2

Node.js version

14.18.0 & 16

npm version

6.14.15

What operating system are you seeing the problem on?

Linux, macOS, Windows

Relevant log output

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
     at new NodeError (internal/errors.js:322:7)
     at validateString (internal/validators.js:124:11)
     at Object.join (path.js:1148:7)
     at new BrowserFetcher (webpack:////Users/codydaig/dev/opensource/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js?:162:22)
     at resolveExecutablePath (webpack:////Users/codydaig/dev/opensource/puppeteer/lib/cjs/puppeteer/node/Launcher.js?:610:28)
     at ChromeLauncher.launch (webpack:////Users/codydaig/dev/opensource/puppeteer/lib/cjs/puppeteer/node/Launcher.js?:107:57) {
   code: 'ERR_INVALID_ARG_TYPE'
 }
@codydaig codydaig added the bug label Jan 26, 2022
codydaig added a commit to codydaig/puppeteer that referenced this issue Jan 26, 2022
This patch fixes __dirname pointing to / in some envrioments by
trying process.cwd() if __dirname returne undefined.

Issues: puppeteer#7085 puppeteer#7932
OrKoN pushed a commit to codydaig/puppeteer that referenced this issue Feb 7, 2022
This patch fixes __dirname pointing to / in some envrioments by
trying process.cwd() if __dirname returne undefined.

Issues: puppeteer#7085 puppeteer#7932
@OrKoN
Copy link
Collaborator

OrKoN commented Feb 14, 2022

This should be solved via #8003

@OrKoN OrKoN closed this as completed Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants