Skip to content

Instantly share code, notes, and snippets.

@xl1
Created September 3, 2022 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xl1/faf7d7baa2d192de9597b0a0829b09b9 to your computer and use it in GitHub Desktop.
Save xl1/faf7d7baa2d192de9597b0a0829b09b9 to your computer and use it in GitHub Desktop.
Azure SWA の node version 指定

Azure SWA の node version 指定

Azure Static Web Apps で API をビルド/実行する node のバージョンを指定したい

検索すると、package.json で engines.node>=16.0.0 と指定すると 14 でなく 16 を使うようにできる、という記事がいくつかある

しかし、これでは app(フロントエンドアプリ)をビルドするバージョンを変更することはできるが、API のほうは変更できない (そもそも、どういう理由か不明だがバージョン 14 どころか 12 が使われてしまっている)

API 用の node バージョンは staticwebapp.config.json ファイルで設定できる

{
  "platform": {
    "apiRuntime": "node:16"
  }
}

ランタイムバージョンを変更すると API のビルドバージョンも同じく v16.14.2(2022/9/3 現在)に変更される

  • v18 はまだサポートされてないようである

staticwebapp.config.json はルートディレクトリではなく frontend のディレクトリに置くので、API の設定がここにあるのはちょっと不思議な感じもする

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment