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.

【Next.js】Error: Cannot find module './undefined' とでてしまうときの処方箋

Posted at

Next.jsの開発をしてて、

  • npm run dev では問題ない
  • よし、 npm run build だ。通ったぞ
  • npm run start だ。通ったぞ
  • ページにアクセス! InternalServer Error!
  • ターミナルには、 Error: Cannot find module './undefined' とかでてて意味わからん

となってる人向けです。

原因:PATHが通ってないため

export NODE_PATH=`npm root -g`

これを叩いてから、もう一度、
npm run build -> npm run start をすればいけるようになりました。(buildからやりなおすこと)

参考文献:
https://qiita.com/DNA1980/items/11fdb7233fc288ac3502

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?