How to Uninstall Playwright?
How to Uninstall Playwright (Node.js, Python, .NET Guide)
There are situations where keeping Playwright in the project no longer makes sense. The project might be moving to another testing framework. The environment might need cleanup. Sometimes the goal is simply to remove unused dependencies that slow down builds or clutter the setup.
What surprises many testers is that uninstalling Playwright is rarely just a single command. Removing the package does not always remove the browsers it downloaded. In some setups, configuration files, cache directories, or CI images may still contain leftover components. The result is a system that technically “uninstalled” Playwright but still carries pieces of it.
I have seen this happen when cleaning up test environments or preparing a project to migrate to another tool. Everything looked removed at first glance, yet browser binaries were still sitting in the cache and pipelines were still referencing old configurations.
So the real question is not just how to uninstall Playwright, but how to remove it completely without leaving artifacts behind.
This guide walks through the full process. It covers how to uninstall Playwright in Node.js, JavaScript, TypeScript, Python, and .NET projects.
When It Makes Sense to Uninstall Playwright
Playwright is widely used for browser automation and end to end testing, but there are scenarios where removing it from a project becomes necessary. Over time, test environments evolve. Frameworks change, pipelines get optimized, and unused dependencies start creating unnecessary overhead.
Some common situations where it makes sense to uninstall Playwright include:
- Migrating to another testing framework: Teams sometimes move to tools like Cypress, Selenium, or framework specific testing utilities. Once the migration is complete, keeping Playwright in the dependency list only increases maintenance effort and build complexity.
- Removing unused dependencies from a project: Projects evolve quickly and testing tools that were once used actively may become obsolete. Removing unused packages like Playwright reduces dependency bloat and keeps the repository easier to maintain.
- Simplifying CI/CD pipelines: Playwright downloads browser binaries and installs runtime dependencies during setup. If the framework is no longer required, uninstalling it helps reduce build steps and speeds up CI pipeline execution.
- Cleaning up local development environments: Developers and testers often install frameworks while evaluating automation strategies. If Playwright was installed only for experimentation, removing it helps clean up browser binaries and cached files.
- Preparing minimal Docker or container environments: Some teams aim to keep container images small and optimized. Removing Playwright and its browser dependencies can significantly reduce image size and dependency complexity.
In most of these scenarios, the goal is not only to uninstall the Playwright package but also to ensure that browser binaries, cached files, and configuration references are fully removed. The next section explains the key steps to consider before uninstalling Playwright so that the process does not break existing workflows.
Key Steps to Consider Before Uninstalling Playwright
Before uninstalling Playwright, it helps to check how deeply it is integrated into the project. In many test environments, Playwright is not only a dependency but also part of the test framework setup, CI pipelines, and browser management process.
If Playwright is removed without reviewing these connections, it can leave broken scripts, failing pipelines, or unused browser binaries in the system. A quick review of the project setup ensures that uninstalling Playwright does not disrupt existing workflows.
The following steps help ensure the removal process is clean and does not introduce unexpected issues.
- Review test scripts and framework usage: Many projects reference Playwright directly inside test scripts, configuration files, or test runners. Before uninstalling, check whether any tests still depend on Playwright APIs such as browser launch commands, page interactions, or fixtures.
- Check the project dependency files: Playwright is typically installed through package managers like npm, pip, or NuGet. Reviewing files such as package.json, requirements.txt, or .csproj helps confirm whether Playwright is listed as a dependency and whether related packages like @playwright/test are also installed.
- Identify Playwright browser downloads: Playwright automatically downloads browser binaries during installation. These binaries are stored separately from the project dependencies. Removing the package does not always remove these browsers, so it is useful to identify where they are stored before uninstalling.
- Review CI/CD pipeline configurations: Many pipelines include steps that install Playwright browsers or run Playwright tests. If the framework is removed without updating pipeline scripts, CI jobs may fail due to missing commands or dependencies.
- Check Docker images or container setups: Some projects include Playwright inside Docker images for browser testing. In these cases, uninstalling Playwright also requires updating the Dockerfile to remove related installation steps.
How to Uninstall Playwright in Node.js, JavaScript, and TypeScript
In Node.js based projects, Playwright is usually installed through npm, yarn, or pnpm. The framework may appear as playwright or @playwright/test depending on whether the project uses the Playwright Test runner.
Uninstalling Playwright from a Node.js project mainly involves removing the package dependency and ensuring that browser binaries downloaded during installation are also cleaned up.
Step 1: Identify the Playwright Package in the Project
Before removing Playwright, check the package.json file in the project. Playwright is commonly installed in one of the following forms:
"dependencies": { "playwright": "^1.40.0" }
or
"devDependencies": { "@playwright/test": "^1.40.0" }
This helps confirm which package needs to be removed.
Step 2: Uninstall the Playwright Package
Run the uninstall command based on the package manager used in the project.
Using npm
npm uninstall playwrightIf the project uses the Playwright test runner:
npm uninstall @playwright/testUsing yarn
yarn remove playwrightor
yarn remove @playwright/testUsing pnpm
pnpm remove playwrightor
pnpm remove @playwright/testThese commands remove Playwright from the project dependencies and update the package.json and lock files accordingly.
Step 3: Remove Playwright Browser Binaries
During installation, Playwright downloads browsers such as Chromium, Firefox, and WebKit. These binaries are stored in a cache directory and may remain even after the package is removed.
To remove the downloaded browsers, run:
npx playwright uninstallThis command deletes the Playwright managed browser binaries from the system.
Step 4: Clean Up Playwright Configuration Files
Some projects contain configuration files that are specific to Playwright. These files may remain after uninstalling the package and should be removed if the framework is no longer used.
Common Playwright files include:
- playwright.config.ts / playwright.config.js: Defines Playwright test configuration.
- tests or e2e folders: Test directories that contain Playwright scripts.
- playwright-report folder: Stores Playwright test reports.
If these files are no longer required, they can be safely removed from the project.
How to Uninstall Playwright in Python
In Python environments, Playwright is typically installed using pip and then configured by downloading browser binaries through a separate installation command. Because of this two step setup, uninstalling Playwright also involves removing both the Python package and the downloaded browsers.
If only the Python package is removed, the browser binaries may still remain on the system. Cleaning up both components ensures the environment is fully cleared.
Follow these steps to uninstall Playwright from a Python project.
Step 1: Verify the Playwright Installation
Before removing the package, confirm that Playwright is installed in the current environment. This is useful when working with multiple virtual environments.
Run the following command:
pip show playwrightIf Playwright is installed, the command will display package details such as version, location, and dependencies.
Step 2: Uninstall the Playwright Python Package
Use pip to remove the Playwright package from the environment.
pip uninstall playwrightIf the project uses a virtual environment, ensure the environment is activated before running the command so the correct installation is removed.
Step 3: Remove Playwright Browser Binaries
Playwright downloads browser binaries such as Chromium, Firefox, and WebKit when the following command is executed during setup.
playwright installThese browsers are stored in a cache directory and may remain after the Python package is removed. To remove the downloaded browsers, run:
playwright uninstallThis command deletes the browsers managed by Playwright.
Step 4: Remove Playwright Dependencies from Project Files
Some Python projects reference Playwright in dependency files or automation scripts. These references should be cleaned up after uninstalling the package.
Common places to check include:
- requirements.txt: May contain playwright as a dependency.
- test automation scripts: Files that import Playwright modules such as from playwright.sync_api import sync_playwright.
- test directories: Folders that store Playwright based automation tests.
Removing these references ensures the project no longer attempts to use Playwright after it has been uninstalled.
How to Uninstall Playwright in .NET Projects
In .NET projects, Playwright is installed as a NuGet package and integrated into the test framework through the Playwright CLI. During setup, the installation process also downloads browser binaries required for automation.
Uninstalling Playwright from a .NET project therefore involves removing the NuGet package and ensuring that the downloaded browsers are cleaned up.
The following steps explain how to uninstall Playwright from a .NET environment.
Step 1: Identify the Playwright Package
Playwright is typically added to a .NET project using the Microsoft.Playwright NuGet package. This dependency usually appears inside the project’s .csproj file.
Example:
<ItemGroup> <PackageReference Include="Microsoft.Playwright" Version="1.40.0" /> </ItemGroup>
Confirming the presence of this package helps ensure the correct dependency is removed.
Step 2: Remove the Playwright NuGet Package
Use the .NET CLI to remove the Playwright package from the project.
dotnet remove package Microsoft.PlaywrightThis command removes the package reference from the project file and updates the dependency configuration.
Alternatively, the package can also be removed using the NuGet Package Manager inside IDEs such as Visual Studio.
Step 3: Remove Downloaded Playwright Browsers
When Playwright is installed in a .NET project, browser binaries are downloaded through the Playwright CLI during the setup process.
These browsers may remain even after the NuGet package is removed. To remove them, run:
playwright uninstallThis command deletes the Playwright managed browser binaries from the system.
Step 4: Clean Up Playwright Configuration and Test Files
After removing the package and browsers, review the project structure for files that were created specifically for Playwright based testing.
Common items to review include:
- Test classes using Playwright APIs: C# files that import namespaces such as Microsoft.Playwright.
- Playwright initialization code: Setup methods used to launch browsers or manage contexts.
- Test configuration files: Any files created to configure Playwright test execution.
Removing or updating these references ensures the project builds correctly after Playwright is uninstalled.
How to Uninstall Playwright in Docker and CI Pipelines
In many projects, Playwright is not installed only on a local machine. It is often part of Docker images or CI/CD pipelines where automated tests run during builds. In these setups, uninstalling Playwright requires updating the environment configuration rather than simply running an uninstall command.
If Playwright remains referenced in Dockerfiles or pipeline scripts, builds may continue installing it automatically even after it is removed from the project. Reviewing these configurations ensures that the framework is fully removed from automated environments.
The following steps help remove Playwright from Docker and CI setups.
Step 1: Update the Dockerfile
If the project uses Docker for running automated tests, the Dockerfile may contain commands that install Playwright and download browsers.
For example:
RUN npm install @playwright/test RUN npx playwright install
To uninstall Playwright from the Docker environment, remove or modify these installation commands. After updating the Dockerfile, rebuild the image so the new configuration takes effect.
docker build -t project-image .Rebuilding the image ensures that the new container does not include Playwright or its browser binaries.
Step 2: Review CI Pipeline Scripts
CI pipelines often install Playwright as part of the build process. This usually appears in configuration files such as:
- .github/workflows/*.yml in GitHub Actions
- .gitlab-ci.yml in GitLab CI
- Jenkinsfile in Jenkins pipelines
Look for commands similar to the following:
npm install @playwright/test npx playwright install
Removing these commands prevents the pipeline from reinstalling Playwright during each build.
Step 3: Remove Playwright From Test Execution Steps
Many pipelines run Playwright tests as part of the build stage. For example:
npx playwright testIf the framework is being removed from the project, these steps should also be deleted or replaced with the commands used by the new testing framework.
Step 4: Clear Cached Dependencies
Some CI systems cache dependencies to speed up builds. If Playwright was previously installed, the cached environment may still contain its packages and browser binaries.
Clearing the dependency cache ensures that the next pipeline run starts with a clean environment.
Examples include:
- Removing cached node_modules directories
- Clearing package manager caches such as npm or pip
- Resetting CI dependency caches
After updating Dockerfiles and CI configurations, run a fresh build to confirm that Playwright is no longer installed or executed during automated tests.
How to Remove Leftover Playwright Files
After uninstalling Playwright, some files may still remain on the system. This happens because Playwright downloads browser binaries and stores them in cache directories that are separate from project dependencies.
If these files are not removed, they continue occupying disk space and may cause confusion when setting up new test environments. Cleaning them ensures Playwright is fully removed from the system.
Check the following locations during cleanup:
- Playwright browser cache directories: Playwright downloads Chromium, Firefox, and WebKit into system cache folders that may remain after uninstalling the package. Common locations include ~/.cache/ms-playwright on Linux and macOS and C:\Users\<username>\AppData\Local\ms-playwright on Windows. Deleting these folders removes the downloaded browser binaries.
- Node.js dependency folders: In Node.js projects, Playwright packages may still exist in node_modules if the uninstall process was incomplete. Removing node_modules and reinstalling dependencies ensures no Playwright packages remain.
- Test reports and artifacts: Playwright test runs generate reports, screenshots, and trace files. These are often stored in directories such as playwright-report or test-results. If Playwright is no longer used, these folders can be removed.
- Temporary CI or build artifacts: CI pipelines sometimes cache dependencies or test outputs. Clearing cached artifacts ensures old Playwright binaries or results are not reused in future builds.
- Configuration and helper files: Files such as playwright.config.ts, Playwright fixtures, or helper utilities may remain in the repository. Removing them prevents future contributors from assuming the project still uses Playwright.
Troubleshooting Playwright Uninstallation Problems
In most cases, uninstalling Playwright is straightforward. However, certain environments may still show Playwright related errors even after the package has been removed. This usually happens because of cached dependencies, leftover browser binaries, or scripts that still reference Playwright commands.
Reviewing these common scenarios helps identify why Playwright may still appear in the environment after the uninstall process.
- Playwright command still works after uninstall: This usually happens when Playwright browsers or CLI tools remain in the system cache. Running npx playwright uninstall or deleting the ms-playwright cache directory helps remove these remaining components.
- CI pipelines continue installing Playwright: Some pipelines include explicit installation steps such as npm install @playwright/test or npx playwright install. If these commands remain in pipeline configuration files, the framework will continue to install during every build.
- Build or test scripts fail after removal: Test scripts or automation tasks may still reference commands like npx playwright test. Removing or replacing these commands ensures that the build process does not attempt to execute Playwright tests.
- Browser binaries still consume disk space: Even after removing the Playwright package, downloaded browsers may remain in the cache directory. Deleting the ms-playwright folder removes these binaries and frees up disk space.
- Dependency lock files still reference Playwright: Files such as package-lock.json, yarn.lock, or pnpm-lock.yaml may still contain Playwright references. Regenerating these files after uninstalling dependencies ensures the project dependency graph is updated.
Conclusion
Uninstall Playwright by removing the package from the project, deleting the downloaded browsers, clearing the Playwright cache directory, and removing Playwright commands from CI pipelines and scripts. After these steps, Playwright is no longer installed in the environment and the project no longer runs Playwright tests during builds or test execution.
Related Articles
Playwright Install Guide: Setup for Node, Python, Java & .NET
Learn how to install Playwright step by step for Node.js, Python, Java, and .NET. Verify installatio...
Playwright Architecture: Client, Server, Browsers Explained
Playwright architecture defines how tests interact with browsers through its core components. Learn ...
Master Playwright Config for Efficient Test Automation
Playwright config defines how tests run and behave. Learn how to configure browsers, devices, and pa...