YSNHatenaBlog

主にアプリやWebサービス開発について

Next.jsのバージョンを上げた

Next.jsのバージョンを上げている - YSNHatenaBlog

前回記事でNext.jsのバージョンを上げてハマっていうたけど、何も問題なかった。

Server Error
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
pages/_document.tsx (71:4) @ Object.ctx.renderPage

  69 | 
  70 |   ctx.renderPage = () =>
> 71 |     originalRenderPage({
     |    ^
  72 |       enhanceApp: (App) => (props) => sheets.collect(<App {...props} />),
  73 |     })
  74 | 
Call Stack
Function.Document.getInitialProps
pages/_document.tsx (75:29)
Show collapsed frames

このissueによると、

github.com

package.json更新したりすると発生することがあるらしい。

一旦次のファイルを消して、

  • node_modules
  • dist
  • yarn.lock

yarnし直したら直った。

とりあえずNext.jsとnodeのバージョンは上がった。