2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VercelでNext.jsが `lightningcss.linux-x64-gnu.node` エラーでビルド失敗する原因と対処法

Posted at

VercelでNext.jsアプリをデプロイしようとすると、以下のようなエラーでビルドが失敗することがありました。

An error occurred in `next/font`.
Error: Cannot find module '../lightningcss.linux-x64-gnu.node'

原因

  • Next.jsの next/font は、内部的に lightningcss を使用してフォントCSSの最適化を行う

  • この lightningcss はビルド環境に応じた .node バイナリを必要とするが、VercelのLinux環境で対応するバイナリが見つからずモジュールの読み込みに失敗していた

対処法

next/font の最適化処理を無効化することで回避できました。

環境変数の追加(Vercel)

Vercelのプロジェクト設定で以下の環境変数を追加する。

Key Value
NEXT_DISABLE_OPTIMIZED_FONT_LOADING 1

追加後、Use existing Build Cache のチェックを外して Redeploy を実行

スクリーンショット 2025-06-28 10.34.19.png

補足

  • この設定により、フォント最適化機能は無効になるが、通常のフォント読み込みには影響しない
  • 必要に応じてGoogle Fontsなどを手動で読み込むことで代替可能
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?