Heroku cannot find Playwright files

2k views Asked by At

My TypeScript NodeJS (>=12.0.0) app uses Playwright (^1.4.2). It runs well locally. But, it fails on Heroku:

browserType.launch: Failed to launch chromium because executable doesn't exist at /app/.cache/ms-playwright/chromium-799411/chrome-linux/chrome

Try re-installing playwright with "npm install playwright"

Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.

at BrowserType._wrapApiCall (/app/node_modules/playwright/lib/client/channelOwner.js:78:15)

at BrowserType.launch (/app/node_modules/playwright/lib/client/browserType.js:49:21)

at Object.exports.browserTest (/app/utils.js:34:57)

at Object.<anonymous> (/app/index.js:13:9)

at Module._compile (internal/modules/cjs/loader.js:1076:30)

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)

at Module.load (internal/modules/cjs/loader.js:941:32)

at Function.Module._load (internal/modules/cjs/loader.js:782:14)

at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

So, I SSHed into the Heroku dyno and ran npm install playwright. Got the same error.

Then I thought, how about building it into a Docker image (node:latest) and then deploying it to Heroku? Surely that won't fail. It did. Same error. This image ran perfectly locally.

Following solutions online, I also tried installing several Heroku buildpacks, and using the Chromium and Firefox Playwright flavours specifically. I then tried a thousand and one other things I've forgotten (edit: including mxschmitt heroku-playwright-example).

Anyone come across this issue before?

1

There are 1 answers

1
nusantara On

alterjun and MaxSchmitt point to github.com/mxschmitt/heroku-playwright-buildpack, and it says the buildpacks are important. I tried it previously but must have done something wrong but now it's working.