931d4fced5
🤖 I have created a release *beep* *boop* --- <details><summary>puppeteer: 19.4.0</summary> ## [19.4.0](https://github.com/puppeteer/puppeteer/compare/puppeteer-v19.3.0...puppeteer-v19.4.0) (2022-12-07) ### Features * **chromium:** roll to Chromium 109.0.5412.0 (r1069273) ([#9364](https://github.com/puppeteer/puppeteer/issues/9364)) ([1875da6
](1875da6191
)), closes [#9233](https://github.com/puppeteer/puppeteer/issues/9233) ### Dependencies * The following workspace dependencies were updated * dependencies * puppeteer-core bumped from 19.3.0 to 19.4.0 </details> <details><summary>puppeteer-core: 19.4.0</summary> ## [19.4.0](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v19.3.0...puppeteer-core-v19.4.0) (2022-12-07) ### Features * ability to send headers via ws connection to browser in node.js environment ([#9314](https://github.com/puppeteer/puppeteer/issues/9314)) ([937fffa
](937fffaedc
)), closes [#7218](https://github.com/puppeteer/puppeteer/issues/7218) * **chromium:** roll to Chromium 109.0.5412.0 (r1069273) ([#9364](https://github.com/puppeteer/puppeteer/issues/9364)) ([1875da6
](1875da6191
)), closes [#9233](https://github.com/puppeteer/puppeteer/issues/9233) * **puppeteer-core:** keydown supports commands ([#9357](https://github.com/puppeteer/puppeteer/issues/9357)) ([b7ebc5d
](b7ebc5d9bb
)) ### Bug Fixes * **puppeteer-core:** avoid type instantiation errors ([#9370](https://github.com/puppeteer/puppeteer/issues/9370)) ([17f31a9
](17f31a9ee4
)), closes [#9369](https://github.com/puppeteer/puppeteer/issues/9369) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
132 lines
3.1 KiB
Plaintext
132 lines
3.1 KiB
Plaintext
# Configuration
|
|
|
|
```mdx-code-block
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
```
|
|
|
|
All defaults in Puppeteer can be customized in two ways:
|
|
|
|
1. [Configuration files](#configuration-files) (**recommended**)
|
|
2. [Environment variables](#environment-variables)
|
|
|
|
:::caution
|
|
|
|
Note that some options are only customizable through environment variables (such
|
|
as `HTTPS_PROXY`).
|
|
|
|
:::
|
|
|
|
## Configuration files
|
|
|
|
Configuration files are the **recommended** choice for configuring Puppeteer.
|
|
Puppeteer will look up the file tree for any of the following formats:
|
|
|
|
- `.puppeteerrc.cjs`,
|
|
- `.puppeteerrc.js`,
|
|
- `.puppeteerrc` (YAML/JSON),
|
|
- `.puppeteerrc.json`,
|
|
- `.puppeteerrc.yaml`,
|
|
- `puppeteer.config.js`, and
|
|
- `puppeteer.config.cjs`
|
|
|
|
Puppeteer will also read a `puppeteer` key from your application's
|
|
`package.json`.
|
|
|
|
See the [`Configuration`](../api/puppeteer.configuration) interface for possible
|
|
options.
|
|
|
|
:::caution
|
|
|
|
After adding a configuration file, you may need to remove and reinstall
|
|
`puppeteer` for it to take effect if the changes affect installation.
|
|
|
|
:::
|
|
|
|
### Examples
|
|
|
|
#### Changing the default cache directory
|
|
|
|
Starting in v19.0.0, Puppeteer stores browsers in `~/.cache/puppeteer` to
|
|
globally cache browsers between installation. This can cause problems if
|
|
`puppeteer` is packed during some build step and moved to a fresh location. The
|
|
following configuration can solve this issue (reinstall `puppeteer` to take
|
|
effect):
|
|
|
|
```js title="project-directory/.puppeteerrc.cjs"
|
|
const {join} = require('path');
|
|
|
|
/**
|
|
* @type {import("puppeteer").Configuration}
|
|
*/
|
|
module.exports = {
|
|
// Changes the cache location for Puppeteer.
|
|
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
|
|
};
|
|
```
|
|
|
|
:::note
|
|
|
|
Notice this is only possible with CommonJS configuration files as information
|
|
about the ambient environment is needed (in this case, `__dirname`).
|
|
|
|
:::
|
|
|
|
#### Enabling experiments
|
|
|
|
By default, experiments are turned off, but they can be individually turned on
|
|
using the [`experiments`](../api/puppeteer.configuration.experiments) key.
|
|
|
|
For example, if you want to enable ARM-native macOS chromium, you can use
|
|
|
|
<Tabs>
|
|
<TabItem value="CommonJS">
|
|
|
|
```js title=".puppeteerrc.cjs"
|
|
/**
|
|
* @type {import("puppeteer").Configuration}
|
|
*/
|
|
module.exports = {
|
|
experiments: {
|
|
macArmChromiumEnabled: true,
|
|
},
|
|
};
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="JSON">
|
|
|
|
```json title=".puppeteerrc.json"
|
|
{
|
|
"experiments": {
|
|
"macArmChromiumEnabled": true
|
|
}
|
|
}
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="YAML">
|
|
|
|
```yaml title=".puppeteerrc.yaml"
|
|
experiments:
|
|
macArmChromiumEnabled: true
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
## Environment variables
|
|
|
|
Along with configuration files, Puppeteer looks for certain
|
|
[environment variables](https://en.wikipedia.org/wiki/Environment_variable) for
|
|
customizing behavior. Environment variables will always override configuration
|
|
file options when applicable.
|
|
|
|
The following options are _environment-only_ options
|
|
|
|
- `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY` - defines HTTP proxy settings that are
|
|
used to download and run the browser.
|
|
|
|
All other options can be found in the documentation for the
|
|
[`Configuration`](../api/puppeteer.configuration) interface.
|