当ブログでは
rehype-mermaid が
今回は
開発環境
- Node.js: v20.15.0
(Vercel では v20 を 指定) - @playwright/test: v1.45.1
Node20 に アップグレードする
Node18 からVercel ビルド時は
Vercel ビルド時のpackage.json
のengines#node
をpackage.json
に
{ "name": "@kkhys/web", // ... "engines": { "node": ">=20.15.0" }, // ...}
ちなみに
{ "name": "root", // ... "packageManager": "pnpm@8.14.1", // ...}
これで
Playwright を インストールする
ビルド時にVercel ビルド時はturbo run build
が
{ "name": "@kkhys/web", // ... "scripts": { "playwright-install": "pnpx playwright-core install chromium", }, // ...}
package.json
のplaywright-install
と
Playwright の--with-deps
を
sh: apt-get: command not foundFailed to install browsersError: Installation process exited with code: 127ELIFECYCLE Command failed with exit code 1.Error: Command "pnpm playwright-install && turbo run build" exited with 1
仕方
Vercel ビルド時のvercel.json
でvercel.json
を
{ "$schema": "https://openapi.vercel.sh/vercel.json", "buildCommand": "pnpm playwright-install && turbo run build"}
vercel.json
は
3 行目でpackage.json
に
追加の パッケージを インストールする
ビルドコンテナに上述した
╔══════════════════════════════════════════════════════╗║ Host system is missing dependencies to run browsers. ║║ Please install them with the following command: ║║ ║║ pnpm exec playwright install-deps ║║ ║║ Alternatively, use apt: ║║ apt-get install libnss3\ ║║ libnspr4\ ║║ libgbm1 ║║ ║║ <3 Playwright Team ║╚══════════════════════════════════════════════════════╝
Playwright インストール時に--with-deps
オプションを
ちなみに
Vercel デプロイ時のapt-get
をdnf install
を
- libnss3 → nss
- libnspr4 → nspr
- libgbm1 → mesa-libgbm
念の
# Docker コンテナを作成して実行するdocker run --rm -it amazonlinux:2023.2.20231011.0 sh
# nss があるかチェック -> あるdnf search nss
# nspr があるかチェック -> あるdnf search nspr
# mesa-libgbm があるかチェック -> あるdnf search mesa-libgbm
# それぞれインストールするdnf install -y nss nspr mesa-libgbm
exit
問題なくvercel.json
に
{ "$schema": "https://openapi.vercel.sh/vercel.json", "buildCommand": "pnpm playwright-install && turbo run build", "installCommand": "pnpm install && dnf install -y nss nspr mesa-libgbm"}
これで
ごに
さいそも
Mermaid が