mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
e0932e5cce
🤖 I have created a release *beep* *boop* --- <details><summary>browsers: 2.2.2</summary> ## [2.2.2](https://github.com/puppeteer/puppeteer/compare/browsers-v2.2.1...browsers-v2.2.2) (2024-04-15) ### Bug Fixes * remove NetworkServiceInProcess2 set by default ([#12261](https://github.com/puppeteer/puppeteer/issues/12261)) ([ff4f70f
](ff4f70f4ae
)), closes [#12257](https://github.com/puppeteer/puppeteer/issues/12257) </details> <details><summary>puppeteer: 22.6.5</summary> ## [22.6.5](https://github.com/puppeteer/puppeteer/compare/puppeteer-v22.6.4...puppeteer-v22.6.5) (2024-04-15) ### Miscellaneous Chores * **puppeteer:** Synchronize puppeteer versions ### Dependencies * The following workspace dependencies were updated * dependencies * puppeteer-core bumped from 22.6.4 to 22.6.5 * @puppeteer/browsers bumped from 2.2.1 to 2.2.2 </details> <details><summary>puppeteer-core: 22.6.5</summary> ## [22.6.5](https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v22.6.4...puppeteer-core-v22.6.5) (2024-04-15) ### Bug Fixes * remove NetworkServiceInProcess2 set by default ([#12261](https://github.com/puppeteer/puppeteer/issues/12261)) ([ff4f70f
](ff4f70f4ae
)), closes [#12257](https://github.com/puppeteer/puppeteer/issues/12257) * use setImmediate to reduce flakiness when processing events ([#12264](https://github.com/puppeteer/puppeteer/issues/12264)) ([73403b3
](73403b323e
)) ### Dependencies * The following workspace dependencies were updated * dependencies * @puppeteer/browsers bumped from 2.2.1 to 2.2.2 </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>
112 lines
3.1 KiB
Plaintext
112 lines
3.1 KiB
Plaintext
# Configuration
|
|
|
|
By default, Puppeteer downloads and uses a specific version of Chrome so its
|
|
API is guaranteed to work out of the box. To use Puppeteer with a different
|
|
version of Chrome or Chromium, pass in the executable's path when creating a
|
|
`Browser` instance:
|
|
|
|
```ts
|
|
const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});
|
|
```
|
|
|
|
You can also use Puppeteer with Firefox. See
|
|
[status of cross-browser support](https://pptr.dev/faq#q-what-is-the-status-of-cross-browser-support) for
|
|
more information.
|
|
|
|
```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`).
|
|
|
|
:::
|
|
|
|
:::caution
|
|
|
|
Puppeteer's configuration files and environment variables are ignored by `puppeteer-core`.
|
|
|
|
:::
|
|
|
|
## 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`
|
|
|
|
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.
|
|
|
|
:::
|
|
|
|
:::caution
|
|
|
|
Previous versions of Puppeteer allowed configuration via the `config` key in
|
|
`package.json`. This behavior is now deprecated and will be removed in the future.
|
|
|
|
:::
|
|
|
|
### 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`).
|
|
|
|
:::
|
|
|
|
## 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.
|