Next.js Vercelでエラー 1
ITカレッジ沖縄の学生が
Nextの講義で起こるエラーの一つです。
下記のエラーをみて、
同じ症状であれば試してみてください。
更新日 2023年1月24日
対象・環境
対象学科
ITスペシャリスト科
サイバーセキュリティ科
環境
ホストPC
Ubuntu 22.04
VirtualBox 7.0.12
Vagrant 2.4.0
仮想環境
Box ubuntu/jammy64
Ubuntu 22.04
Next環境
Volta 1.1.1
Node.js 20.10
npm 10.2.4
Next.js 14.0.3 → 14.1.0
plaiceholder 2.5.0
shap 0.33.2 → sharp-linux-x64 0.33.2
教科書
症状&エラー
書籍「作って学ぶ Next.js/React Webサイト構築」の
Chapter9の「plaiceholder」「sharp」をインストールした時点で
下記のエラーがでる場合に試してみてください。
「plaiceholder」「sharp」をインストール後
仮想環境ではデプロイできる `npm run build`
Vercelで「RangeError: Maximum call stack size exceeded」のエラーがでる
RangeError: Maximum call stack size exceeded
at parse (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:6313)
at picomatch.makeRe (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:21670)
at picomatch (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:19637)
at /vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:19294
at Array.map (<anonymous>)
at picomatch (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:19286)
at micromatch.isMatch (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:1090)
at /vercel/path0/node_modules/next/dist/build/collect-build-traces.js:244:48
at shouldIgnore (/vercel/path0/node_modules/next/dist/build/collect-build-traces.js:75:9)
at /vercel/path0/node_modules/next/dist/build/collect-build-traces.js:86:23
Error: Command "npm run build" exited with 1
対処
Vercelでのshapモジュール関連のエラーとなっており、
sharpモジュールのlinux版のインストール
Nextのバージョンアップ(14.0.3 → 14.1.0)
を行うことで解消される可能性があります。
Next環境
Next.js 14.0.3 → 14.1.0
plaiceholder 2.5.0
shap 0.33.2 → sharp-linux-x64 0.33.2
npm i --os=linux --cpu=x64 sharp
npm i --force @img/sharp-linux-x64
npm i next@14.1.0
sharp モジュールの linux 版を明示的に入れる宣言
強制的に sharp モジュールの linux 版をインストール
next のバージョンアップ
上記の作業後、
package-lock.json
package.json
が更新されるので
Gitでのアップ、コミット、プッシュも行って
Vercelでの更新を確認してください。