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] npm init playwright fails

See original GitHub issue

Hi! I am new here. Trying to get started with Playwright in one of my projects.

Context:

  • Playwright Version: 1.21.0
  • Operating System: Ubuntu 20.04.4 LTS running under WSL2, Windows 10 Pro, 21H2, 19044.1586
  • Node.js version: v16.13.1
  • Browser: All
  • Extra:

Code Snippet

npm init playwright

Describe the bug

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libegl-mesa0 : Depends: libgbm1 (= 21.2.6-0ubuntu0.1~20.04.1) but 21.2.6-0ubuntu0.1~20.04.2 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
Failed to install browsers
Error: Installation process exited with code: 100
Error: Command failed: npx playwright install --with-deps
    at checkExecSyncError (node:child_process:826:11)
    at execSync (node:child_process:900:15)
    at executeCommands (/home/einar/.npm/_npx/d40a10098bccdd29/node_modules/create-playwright/lib/index.js:4519:39)
    at Generator.run (/home/einar/.npm/_npx/d40a10098bccdd29/node_modules/create-playwright/lib/index.js:4593:5)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /home/einar/.npm/_npx/d40a10098bccdd29/node_modules/create-playwright/lib/index.js:4770:3 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 9825,
  stdout: null,
  stderr: null
}
npm ERR! code 1

Where to go from here? Am I doing something wrong? Is this a common error? If so, please add to docs / getting started…

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
einarperssoncommented, Apr 14, 2022

Alright. I cleaned my apt cache, ran apt update and apt upgrade. Then I ran npm init playwright@latest and after that sudo npx playwright install-deps.

Now it works! 🎉

Detail: running npx playwright show-report does not work out of the box, but if I change the url to localhost it does. Probably something wsl2-related but nvm.

Closing. Thanks for your response(s)

0reactions
ltsudacommented, Apr 13, 2022

For me it’s working in this setup:

Windows 11 WSL2 - Ubuntu 20.04.4 LTS Node v16.13.1

❯ npm init playwright
Need to install the following packages:
  create-playwright
Ok to proceed? (y) y
Getting started with writing end-to-end tests with Playwright:
Initializing project in '.'
✔ Do you want to use TypeScript or JavaScript? · JavaScript
✔ Where to put your end-to-end tests? · tests
✔ Add a GitHub Actions workflow? (Y/n) · false
✔ Install Playwright operating system dependencies (requires sudo / root - can be done manually via sudo npx playwright install-deps')? (y/N) · true

Initializing NPM project (npm init -y)…
Wrote to /home/ltsuda/test/package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


Installing Playwright Test (npm install --save-dev @playwright/test)…

added 189 packages, and audited 190 packages in 7s

16 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Downloading browsers (npx playwright install --with-deps)…
Installing Ubuntu dependencies...
Switching to root user to install dependencies...
[sudo] password for ltsuda:

####### SUPPRESSED TO REDUCE LOG ######

xvfb is already the newest version (2:1.20.13-1ubuntu1~20.04.2).
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
Writing playwright.config.js.
Writing tests/example.spec.js.
Writing package.json.
✔ Success! Created a Playwright Test project at /home/ltsuda/test
Inside that directory, you can run several commands:

  npx playwright test
    Runs the end-to-end tests.

  npx playwright test --project=chromium
    Runs the tests only on Desktop Chrome.

  npx playwright test tests/example.spec.js
    Runs the tests of a specific file.

  npx playwright test --debug
    Runs the tests in debug mode.

We suggest that you begin by typing:

  npx playwright test

And check out the following files:
  - ./tests/example.spec.js - Example end-to-end test
  - ./playwright.config.js - Playwright Test configuration

Visit https://playwright.dev/docs/intro for more information. ✨

Happy **hacking!**

❯ npx playwright --version
Version 1.21.0

❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal
Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing playwright using npm gives error `command failed`
I tried to install playwright using the command npm i playwright. But got an error npm ERR! code 1 npm ERR! path ...
Read more >
playwright - npm
Run from your project's root directory npm init playwright@latest # Or ... Capture all the information to investigate the test failure.
Read more >
Cannot find module '@playwright/test' error in Node.js
The error "Cannot find name '@playwright/test'" occurs when we import the @playwright/test module before installing it. To solve the error, ...
Read more >
How to Install Playwright - YouTube
The steps for installing Playwright are the same no matter which operating system you use. Ensure you have Node JS, and Visual Studio...
Read more >
How To Run End-to-End Tests Using Playwright and Docker
You need a sudo-enabled account to install NodeJS and Docker on your ... navigation and compiler error warning when working in Typescript.
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