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?

Next.js 開発環境起動直後にエラー

0
Posted at

はじめに

Next.js で開発環境起動後にエラーが起きたので、その解決方法をまとめました。
これに関しては前にも同じことが起きていたのですが、時間が経ちすぎて解決方法を忘れてしまって、再度調べることになったので、個人的な備忘録として記録しておきます。

事象

Next.js プロジェクトをnpm run devコマンドで開発環境を起動させ、localhostの画面を開いた際に、以下のようなエラーが表示された。

Could not parse module '[project]/node_modules/next/app.js', file not found
Unexpected non-whitespace character after JSON at position ~

解決方法

プロジェクトフォルダ内直下にある、.nextフォルダと、node_modulesフォルダを削除した後、npm installで解決。

rm -rf .next
rm -rf node_modules
npm install

簡単な説明

  • .next
    Next.js が開発・ビルド時に生成する、モジュール構成などの情報を持つ、キャッシュ・生成物。
  • node_modules
    プロジェクトで利用する外部パッケージ(ライブラリ)が保存されるフォルダ。

つまり、これらを削除することで、ソースコード・依存関係などを再生成(リセット)させた形となります。

以上です。

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?