0
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?

More than 3 years have passed since last update.

Vercelへのデプロイ時にModule Not Found Error

Posted at

問題の概要

Next.jsプロジェクトをVercelにデプロイをかけたところ、Module Not Found Errorが発生し、ビルドに失敗した。

00:00:00  	Failed to compile.
00:00:00  	ModuleNotFoundError: Module not found: Error: Can't resolve 'chart.js/auto' in '/vercel/path0/node_modules/react-chartjs-2/dist'
00:00:00  	> Build error occurred
00:00:00  	Error: > Build failed because of webpack errors
00:00:00  	    at /vercel/path0/node_modules/next/dist/build/index.js:15:924
00:00:00  	    at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)

なお、エラーが発生したNext.jsプロジェクトは、Chart.jsを使用しアプリ内でグラフ表示を行っていた。

解決

プロジェクト内のpackage.jsonを確認したところ、chart.jsではなくchartパッケージがインストールされていた。

下記コマンドでchart.jsパッケージをインストールしたところ、エラーは解消されました。

npm uninstall chart react-chartjs-2
npm install --save chart.js react-chartjs-2
0
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
0
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?