-
-
Couldn't load subscription status.
- Fork 295
HOWTO: Local Development
This project is compiled specifically for AWS Lambda (Linux x64)
Therefore the binary might not be compatible with your local system, making development trickier.
The headless getter returns a boolean indicating if we are running on a serverless environment.
If it returns false, it will cause the following side-effects:
- the
argsgetter will return different flags-
--single-processflag will be omitted -
--start-maximizedflag with be present
-
- the
defaultViewportgetter will return a different configuration-
width=0(maximized) instead ofwidth=1920 -
height=0(maximized) instead ofheight=1080
-
- the
font()method becomes no-op to avoid polluting the user space - the
executablePathgetter returnsnulland Chromium / SwiftShader will not be extracted
It's possible to trick the headless getter into returning true by setting any of the following:
-
AWS_LAMBDA_FUNCTION_NAME(used by AWS Lambda) -
FUNCTION_NAME(used by Google Cloud Functions) -
FUNCTION_TARGET(used by Google Cloud Functions)
Additionally, to use the bundled iltorb module, you need to be running Node 8.10 and set:
AWS_EXECUTION_ENV=AWS_Lambda_nodejs8.10
Note that this approach is not recommended, as it may not be compatible with your system.
On Node v10.16.0+, native Brotli is used instead, so the bundled iltorb is no longer necessary.
The suggested workaround is to install puppeteer as a development dependency.
npm install puppeteer-core chrome-aws-lambda --save-prod
npm install puppeteer --save-devThe provided puppeteer getter will return the resolved puppeteer package.
First it will try to load puppeteer and, only if that's not available, fallback to loading puppeteer-core - if puppeteer-code is also not available, then a MODULE_NOT_FOUND error is thrown.
As long as your deployment pipeline skips bundling devDependencies, this approach allows us to rely on puppeteer for local development and puppeteer-core for production deployments.