I added a new feature on my app which includes the usages of playwright-aws-lambda
in a page's static props.
When I deploy my app, I am receiving the following error saying:
Error occurred prerendering page "/url/of/some/page". Read more: https://nextjs.org/docs/messages/prerender-error
at Object.launchChromium (/vercel/path0/node_modules/playwright-aws-lambda/dist/src/chromium.js:97:47)
at async generateOgImage (/vercel/path0/.next/server/pages/blog/[...slug].js:21:21)
at async getStaticProps (/vercel/path0/.next/server/pages/blog/[...slug].js:122:25)
at async renderToHTML (/vercel/path0/node_modules/next/dist/server/render.js:470:20)
at async /vercel/path0/node_modules/next/dist/export/worker.js:253:36
at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:79:20)
there is also an other message which is not part of an error or warning that says:
browserType.launch: Executable doesn't exist at /vercel/.cache/ms-playwright/chromium-1019/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ npx playwright install ║
║ ║
║ <3 Playwright Team ║
╚═════════════════════════════════════════════════════════════════════════╝
I tried running the specified command on my machine but it doesn't do anything on the repo I am deploying. How can I resolve the issue?
I ended up solving this by running the command shown in the logs in my build script:
// package.json
{
"scripts": {
// ...
"build": "next build && npx playwright install",
},
}