install.mjs 917 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env node
  2. /**
  3. * @license
  4. * Copyright 2017 Google Inc.
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. /**
  8. * This file is part of public API.
  9. *
  10. * By default, the `puppeteer` package runs this script during the installation
  11. * process unless one of the env flags is provided.
  12. * `puppeteer-core` package doesn't include this step at all. However, it's
  13. * still possible to install a supported browser using this script when
  14. * necessary.
  15. */
  16. async function importInstaller() {
  17. try {
  18. return await import('puppeteer/internal/node/install.js');
  19. } catch {
  20. console.warn(
  21. 'Skipping browser installation because the Puppeteer build is not available. Run `npm install` again after you have re-built Puppeteer.'
  22. );
  23. process.exit(0);
  24. }
  25. }
  26. try {
  27. const {downloadBrowser} = await importInstaller();
  28. downloadBrowser();
  29. } catch (error) {
  30. console.warn('Browser download failed', error);
  31. }