【问题标题】:Heroku cannot find Playwright filesHeroku 找不到 Playwright 文件
【发布时间】:2021-01-19 16:45:54
【问题描述】:

我的 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 映像(节点:最新)中,然后将其部署到 Heroku?肯定不会失败的。它做了。同样的错误。此图像在本地完美运行。

按照在线解决方案,我还尝试安装几个 Heroku buildpack,并专门使用 ChromiumFirefox Playwright 风格。然后我尝试了一千零一件我忘记的事情(编辑:包括mxschmitt heroku-playwright-example)。

以前有人遇到过这个问题吗?

【问题讨论】:

  • 谢谢@altarjun,但我已经尝试过了。
  • 嗨,这里是剧作家 Heroku buildpack 的作者,您是否使用 buildpack 作为 buildpack 列表中的第一个?顺序很重要,否则浏览器将无法安装并正确找到。 github.com/mxschmitt/heroku-playwright-buildpack
  • @MaxSchmitt 我以为我已经尝试过了,但我今天重试了它,它奏效了。也许我之前做错了什么。谢谢!

标签: node.js docker heroku deployment playwright


【解决方案1】:

alterjun 和 MaxSchmitt 指向github.com/mxschmitt/heroku-playwright-buildpack,它说构建包很重要。我之前尝试过,但一定是做错了什么,但现在可以了。

【讨论】:

    猜你喜欢
    • 2019-04-01
    • 1970-01-01
    • 2018-09-02
    • 2017-07-12
    • 2017-08-07
    • 1970-01-01
    • 1970-01-01
    • 2022-11-07
    • 2012-03-26
    相关资源
    最近更新 更多