我的 TypeScript NodeJS (>=12.0.0) 应用使用Playwright (^1.4.2)。它在本地运行良好。但是,它在 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)
因此,我通过 SSH 连接到 Heroku dyno 并运行npm install playwright
. 得到同样的错误。
然后我想,把它构建成一个 Docker 镜像(node:latest)然后部署到 Heroku 怎么样?肯定不会失败的。它做了。同样的错误。该图像在本地完美运行。
按照在线解决方案,我还尝试安装几个 Heroku buildpack,并专门使用Chromium和Firefox Playwright 风格。然后我尝试了一千零一件我忘记的事情(编辑:包括mxschmitt heroku-playwright-example)。
有人遇到过这个问题吗?