2021-01-01 15:17:27 -08:00
---
id: installation
title: "Advanced installation"
---
2020-12-30 18:04:51 -08:00
2020-04-24 12:20:04 -07:00
- [Managing browser binaries ](#managing-browser-binaries )
2020-04-29 18:59:20 -07:00
- [Download from artifact repository ](#download-from-artifact-repository )
- [Skip browser downloads ](#skip-browser-downloads )
2020-04-24 12:20:04 -07:00
- [Download single browser binary ](#download-single-browser-binary )
2020-04-29 18:59:20 -07:00
2020-04-24 12:20:04 -07:00
## Managing browser binaries
2020-04-21 16:38:40 -07:00
2021-01-01 15:17:27 -08:00
Each version of Playwright needs specific versions of browser binaries to operate. By default Playwright downloads Chromium, WebKit and Firefox browsers into the OS-specific cache folders:
2020-04-30 17:41:56 -07:00
- `%USERPROFILE%\AppData\Local\ms-playwright` on Windows
2020-04-29 18:59:20 -07:00
- `~/Library/Caches/ms-playwright` on MacOS
2020-05-03 16:58:46 +02:00
- `~/.cache/ms-playwright` on Linux
2020-04-21 17:13:14 -07:00
```sh
2020-05-26 10:24:48 -07:00
npm i -D playwright
2020-04-21 17:13:14 -07:00
```
2021-01-01 15:17:27 -08:00
These browsers will take few hundreds of megabytes of the disk space when installed:
2020-04-21 17:13:14 -07:00
```sh
2020-04-29 18:59:20 -07:00
du -hs ./Library/Caches/ms-playwright/*
281M chromium-XXXXXX
2020-05-07 22:33:35 +03:00
187M firefox-XXXX
180M webkit-XXXX
2020-04-21 17:13:14 -07:00
```
2021-01-01 15:17:27 -08:00
You can override default behavior using environment variables. When installing Playwright, ask it to download browsers into a specific location:
2020-04-21 16:38:40 -07:00
2020-04-29 18:59:20 -07:00
```sh
2020-06-13 13:11:39 -07:00
# Linux/macOS
2020-05-26 10:24:48 -07:00
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright
2020-06-13 13:11:39 -07:00
# Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ npm i -D playwright
2020-04-29 18:59:20 -07:00
```
2020-04-21 16:38:40 -07:00
2021-01-01 15:17:27 -08:00
When running Playwright scripts, ask it to search for browsers in a shared location:
2020-04-21 16:38:40 -07:00
2020-04-29 18:59:20 -07:00
```sh
2020-06-13 13:11:39 -07:00
# Linux/macOS
2020-04-29 18:59:20 -07:00
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js
2020-06-13 13:11:39 -07:00
# Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ node playwright-script.js
2020-04-29 18:59:20 -07:00
```
2021-01-01 15:17:27 -08:00
Or you can opt into the hermetic install and place binaries under the `node_modules/` folder:
2020-04-21 16:38:40 -07:00
```sh
2020-06-13 13:11:39 -07:00
# Linux/macOS
$ PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright
# Windows
$ set PLAYWRIGHT_BROWSERS_PATH=0
$ npm i -D playwright
2020-04-21 16:38:40 -07:00
```
2021-01-01 15:17:27 -08:00
Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions.
2020-04-21 16:38:40 -07:00
2021-01-01 15:17:27 -08:00
> **NOTE** Developers can opt-in in this mode via exporting `PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers` in their `.bashrc`.
2020-04-21 16:38:40 -07:00
2020-04-29 18:59:20 -07:00
## Download from artifact repository
2020-04-21 16:38:40 -07:00
2020-04-29 18:59:20 -07:00
By default, Playwright downloads browsers from Microsoft and Google public CDNs.
2021-01-01 15:17:27 -08:00
Sometimes companies maintain an internal artifact repository to host browser binaries. In this case, Playwright can be configured to download from a custom location using the `PLAYWRIGHT_DOWNLOAD_HOST` env variable.
2020-04-21 16:38:40 -07:00
```sh
2020-06-13 13:11:39 -07:00
# Linux/macOS
2020-05-26 10:24:48 -07:00
$ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
2020-06-13 13:11:39 -07:00
# Windows
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
$ npm i -D playwright
2020-04-21 16:38:40 -07:00
```
2021-01-01 15:17:27 -08:00
It is also possible to use a per-browser download hosts using `PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST` , `PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST` and `PLAYWRIGHT_WEBKIT_DOWNLOAD_HOST` env variables that take precedence over `PLAYWRIGHT_DOWNLOAD_HOST` .
2020-06-18 12:35:37 -07:00
```sh
# Linux/macOS
$ PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
```
2020-04-29 18:59:20 -07:00
## Skip browser downloads
2020-04-21 16:38:40 -07:00
2021-01-01 15:17:27 -08:00
In certain cases, it is desired to avoid browser downloads altogether because browser binaries are managed separately.
2020-04-21 16:38:40 -07:00
2021-01-01 15:17:27 -08:00
This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before installation.
2020-04-21 16:38:40 -07:00
```sh
2020-06-13 13:11:39 -07:00
# Linux/macOS
2020-05-26 10:24:48 -07:00
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
2020-06-13 13:11:39 -07:00
# Windows
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
$ npm i -D playwright
2020-04-21 16:38:40 -07:00
```
## Download single browser binary
Playwright ships three packages that bundle only a single browser:
- [`playwright-chromium` ](https://www.npmjs.com/package/playwright-chromium )
- [`playwright-webkit` ](https://www.npmjs.com/package/playwright-webkit )
- [`playwright-firefox` ](https://www.npmjs.com/package/playwright-firefox )
> **NOTE** All configuration environment variables also apply to these packages.
Using these packages is as easy as using a regular Playwright:
2020-04-29 18:59:20 -07:00
Install a specific package
2020-04-21 16:38:40 -07:00
```sh
2020-05-26 10:24:48 -07:00
$ npm i -D playwright-webkit
2020-04-21 16:38:40 -07:00
```
2020-04-29 18:59:20 -07:00
Require package
2020-04-21 16:38:40 -07:00
```js
// Notice a proper package name in require
2020-04-24 12:20:04 -07:00
const { webkit } = require('playwright-webkit');
2020-04-21 16:38:40 -07:00
(async () => {
const browser = await webkit.launch();
2020-06-13 13:11:39 -07:00
// ...
2020-04-21 16:38:40 -07:00
})();
```
2020-12-30 18:04:51 -08:00
2021-01-03 08:47:29 -08:00
2021-01-01 15:17:27 -08:00
[Playwright]: api/class-playwright.md "Playwright"
[Browser]: api/class-browser.md "Browser"
[BrowserContext]: api/class-browsercontext.md "BrowserContext"
[Page]: api/class-page.md "Page"
[Frame]: api/class-frame.md "Frame"
[ElementHandle]: api/class-elementhandle.md "ElementHandle"
[JSHandle]: api/class-jshandle.md "JSHandle"
[ConsoleMessage]: api/class-consolemessage.md "ConsoleMessage"
[Dialog]: api/class-dialog.md "Dialog"
[Download]: api/class-download.md "Download"
[Video]: api/class-video.md "Video"
[FileChooser]: api/class-filechooser.md "FileChooser"
[Keyboard]: api/class-keyboard.md "Keyboard"
[Mouse]: api/class-mouse.md "Mouse"
[Touchscreen]: api/class-touchscreen.md "Touchscreen"
[Request]: api/class-request.md "Request"
[Response]: api/class-response.md "Response"
[Selectors]: api/class-selectors.md "Selectors"
[Route]: api/class-route.md "Route"
[WebSocket]: api/class-websocket.md "WebSocket"
[TimeoutError]: api/class-timeouterror.md "TimeoutError"
[Accessibility]: api/class-accessibility.md "Accessibility"
[Worker]: api/class-worker.md "Worker"
[BrowserServer]: api/class-browserserver.md "BrowserServer"
[BrowserType]: api/class-browsertype.md "BrowserType"
[Logger]: api/class-logger.md "Logger"
[ChromiumBrowser]: api/class-chromiumbrowser.md "ChromiumBrowser"
[ChromiumBrowserContext]: api/class-chromiumbrowsercontext.md "ChromiumBrowserContext"
[ChromiumCoverage]: api/class-chromiumcoverage.md "ChromiumCoverage"
[CDPSession]: api/class-cdpsession.md "CDPSession"
[FirefoxBrowser]: api/class-firefoxbrowser.md "FirefoxBrowser"
[WebKitBrowser]: api/class-webkitbrowser.md "WebKitBrowser"
2020-12-30 18:04:51 -08:00
[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array"
[Buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer "Buffer"
[ChildProcess]: https://nodejs.org/api/child_process.html "ChildProcess"
[Element]: https://developer.mozilla.org/en-US/docs/Web/API/element "Element"
[Error]: https://nodejs.org/api/errors.html#errors_class_error "Error"
2021-01-01 15:17:27 -08:00
[Evaluation Argument]: ./core-concepts.md#evaluationargument "Evaluation Argument"
2020-12-30 18:04:51 -08:00
[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map"
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object"
[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise"
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp "RegExp"
[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"
[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail"
[URL]: https://nodejs.org/api/url.html "URL"
[USKeyboardLayout]: ../src/usKeyboardLayout.ts "USKeyboardLayout"
[UnixTime]: https://en.wikipedia.org/wiki/Unix_time "Unix Time"
[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean"
[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function "Function"
[iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols "Iterator"
[null]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null"
[number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number"
[origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin "Origin"
[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"
[Readable]: https://nodejs.org/api/stream.html#stream_class_stream_readable "Readable"
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string"
[xpath]: https://developer.mozilla.org/en-US/docs/Web/XPath "xpath"