umaar / learn-browser-testing

Repository for my upcoming course & workshop
https://learnbrowsertesting.com/
116 stars 8 forks source link

Puppeteer didn't work for me on Windows #3

Open jensgro opened 4 years ago

jensgro commented 4 years ago

I have node 14.8-0 installed via nvm on Windows10 with WSL1. I installed yarn after calling npm start didn't work. The outcome wasn't better. Be it npm or yarn, the call results mainly with the same errors:

yarn-error

reject(new Error([
                   ^

Error: Failed to launch the browser process!
jensgro commented 4 years ago

I modified the browser-constant that way:

const browser = await puppeteer.launch({
    headless: true,
    ignoreDefaultArgs: ['--disable-extensions'],
    args: ['--no-sandbox', '--disable-setuid-sandbox']
});

The source of the changes were two pages:

  1. https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-windows
  2. https://github.com/puppeteer/puppeteer/issues/1837

It seems to be a known problem, that puppeteer doesn't work on WSL, although it is a slightly crippled Ubuntu.

I did the tests on my private computer because of your decision to use the latest and greatest and I didn't want my business machine have a slightly strange configuration. On my business machine runs node 12.something.

On my business machine a already do tests with puppeteer, so it is no general Windows-problem.

On the other hand: I don't see how I could run it on my private machine "outside" WSL.

umaar commented 4 years ago

Ok interesting so those changes you made, does it work now?

By any chance did you try the version of the code in 1-testing-old-node? I did this to hopefully support older versions of Node.js, where I manually changed each instance of top-level await, and ES Module imports, do use their 'older' counterparts.

I wonder if it would work on your private business computer now?

If the changes you suggested are still not working: I would possibly try these:

npm i -g npx
# Then try npx again

# Remove the package-lock.json file and run
npm cache verify
npm install

# I'm not familiar with WSL as I don't use Windows, but could you try the regular command prompt

So I think 5 things to try:

  1. The solution you posted in your previous comment
  2. Updating npx
  3. Remove package-lock file and node_modules, verify npm cache and npm install
  4. As I have only tested the command prompt in a Virtual Box Windows, please try that instead of WSL
  5. Also try the version 1-testing-old-node on your business machine which uses node 12

Hopefully one of those things works! Unless you already got it working with the solution you mentioned above

jensgro commented 4 years ago

Both changes had no effect. I will hopfeully have the time to test you ideas in the next days. But in the next days I will be very busy. Sorry.