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?

"deploymentId" is undefined | <Html> should not be imported outside of pages/_document.

Posted at

いつも通り意味不明なNext.jsのエラー

エラーメッセージたち

"next dev"の場合

⨯ [TypeError: Cannot read properties of undefined (reading 'deploymentId')]
 ⨯ [TypeError: Cannot read properties of undefined (reading 'deploymentId')]
 GET / 500 in 5411ms
 ✓ Compiled /favicon.ico in 121ms
 ⨯ [TypeError: Cannot read properties of undefined (reading 'buildId')]
 ⨯ [TypeError: Cannot read properties of undefined (reading 'buildId')]

deploymentIdbuildIdもプロジェクト内では使っていません

"next build"の場合

✓ Linting and checking validity of types 
✓ Collecting page data 
// ここまではOK

Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page
    at b (.next/server/pages/_document.js:6:1351)
Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page

(大量のトレースバック)

Export encountered an error on /_error: /404, exiting the build.
 ⨯ Next.js build worker exited with code: 1 and signal: null

エラー系のページは特に作成していないのですべてデフォルトです。デフォルト実装の404ページがエラーしています。

解決策

Nextのキャッシュとインストールしたパッケージをすべて消去すれば治ります。
rm -rf ./.next && rm -rf ./node_modules
Nextを消すほうは一度やった気がするので、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?