diff --git a/docs/guides/configuration.mdx b/docs/guides/configuration.mdx index 4a47d3b7a0d51..f2ae5ff69fc3c 100644 --- a/docs/guides/configuration.mdx +++ b/docs/guides/configuration.mdx @@ -36,9 +36,6 @@ Puppeteer will look up the file tree for any of the following formats: - `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. @@ -49,6 +46,13 @@ After adding a configuration file, you may need to remove and reinstall ::: +:::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 diff --git a/packages/puppeteer/src/getConfiguration.ts b/packages/puppeteer/src/getConfiguration.ts index 6fd88678a454d..ddd3386a7007b 100644 --- a/packages/puppeteer/src/getConfiguration.ts +++ b/packages/puppeteer/src/getConfiguration.ts @@ -127,6 +127,17 @@ export const getConfiguration = (): Configuration => { downloadHost; } + if ( + Object.keys(process.env).some(key => { + return key.startsWith('npm_package_config_puppeteer_'); + }) && + configuration.logLevel === 'warn' + ) { + console.warn( + `Configuring Puppeteer via npm/package.json is deprecated. Use https://pptr.dev/guides/configuration instead.` + ); + } + configuration.cacheDirectory = process.env['PUPPETEER_CACHE_DIR'] ?? process.env['npm_config_puppeteer_cache_dir'] ??