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
fix(initialize-node): __dirname in some envrioments #7933
Conversation
@jackfranklin could you please take a look? |
Why does it work with |
Does it work if you specify the path via |
I don't think you can just rely on You are correct that process.cwd() doesn't return the puppeteer root Directory, but the directory in which they are in, but regardless, i believe they end up resolving the same after pkgDir.sync() finding the project root. I know with this, it was able to find the chromium install inside the node_modules folder. I can double check the Download path env variable in a bit and see if that resolves it. |
This patch fixes __dirname pointing to / in some envrioments by trying process.cwd() if __dirname returne undefined. Issues: puppeteer#7085 puppeteer#7932
codydaig@ actually, have you tried to re-configure webpack to have the proper __dirname? https://codeburst.io/use-webpack-with-dirname-correctly-4cad3b265a92 I am a bit hesitant to merge the CL as is as it'd be installing chromium into the cwd instead of the node_modules/puppeteer folder. It'd be great if you could share a repro as I'd like to get some better understanding of how it works. |
Why not use the |
Opened a PR to use |
That has now landed. I think it should work better than __dirname in Webpack environments. Let me know if it's not the case. |
Thanks! Confirmed that it's fixed. (sorry for the delay, family stuff got in the way). |
This patch fixes __dirname pointing to / in some envrioments by
trying process.cwd() if __dirname returne undefined.
Issues: #7085 #7932
What kind of change does this PR introduce?
Fixes #7932 where certain node environments with webpack don't place nicely to __dirname.
Did you add tests for your changes?
No. This is very difficult to reproduce in simple environments. This change only affects those where __dirname returns undefined on initialization.
If relevant, did you update the documentation?
No relevant documentation updates needed.
Summary
When __dirname points to / it falls back to process.cwd to get the projectRoot on initialization.
Does this PR introduce a breaking change?
No.