fohte / fohte.net

@fohte's portfolio and blog powered by Next.js and MDX
https://fohte.net
Other
1 stars 0 forks source link

Cloudflare Pages でのビルドが失敗する #112

Closed fohte closed 10 months ago

fohte commented 10 months ago

以下のエラーで失敗している。

Error: NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted
エラー全文 ``` 2023-10-29T01:41:44.177521Z Cloning repository... 2023-10-29T01:41:45.090498Z From https://github.com/fohte/fohte.net 2023-10-29T01:41:45.091535Z * branch 0c1046c335acc812f833fff100eb286d85e97eb7 -> FETCH_HEAD 2023-10-29T01:41:45.091746Z 2023-10-29T01:41:45.166975Z HEAD is now at 0c1046c update types 2023-10-29T01:41:45.167715Z 2023-10-29T01:41:45.27946Z 2023-10-29T01:41:45.313685Z Success: Finished cloning repository files 2023-10-29T01:41:48.616845Z Detected the following tools from environment: bun@1.0.6, nodejs@18.18.2 2023-10-29T01:41:48.617988Z Installing nodejs 18.18.2 2023-10-29T01:41:49.275941Z Trying to update node-build... ok 2023-10-29T01:41:49.535912Z Downloading node-v18.18.2-linux-x64.tar.gz... 2023-10-29T01:41:49.536439Z -> https://nodejs.org/dist/v18.18.2/node-v18.18.2-linux-x64.tar.gz 2023-10-29T01:41:51.721963Z 2023-10-29T01:41:51.722476Z WARNING: node-v18.18.2-linux-x64 is in LTS Maintenance mode and nearing its end of life. 2023-10-29T01:41:51.722701Z It only receives *critical* security updates, *critical* bug fixes and documentation updates. 2023-10-29T01:41:51.722841Z 2023-10-29T01:41:51.723003Z Installing node-v18.18.2-linux-x64... 2023-10-29T01:41:53.258366Z Installed node-v18.18.2-linux-x64 to /opt/buildhome/.asdf/installs/nodejs/18.18.2 2023-10-29T01:41:53.25906Z 2023-10-29T01:41:54.680472Z Installing bun 1.0.6 2023-10-29T01:41:54.832635Z Downloading Bun v1.0.6... 2023-10-29T01:41:56.137724Z Archive: /tmp/asdf-bun.5IsD/bun.zip 2023-10-29T01:41:56.956179Z inflating: /opt/buildhome/.asdf/downloads/bun/1.0.6/bun 2023-10-29T01:41:57.026205Z Installing Bun v1.0.6... 2023-10-29T01:41:57.182011Z Bun v1.0.6 is installed successfully! 2023-10-29T01:41:57.580726Z Installing project dependencies: bun install --frozen-lockfile 2023-10-29T01:41:57.870934Z bun install v1.0.6 (969da088) 2023-10-29T01:42:14.774514Z + @types/node@18.18.7 2023-10-29T01:42:14.775056Z + @types/react@18.2.33 2023-10-29T01:42:14.77524Z + @types/react-dom@18.2.14 2023-10-29T01:42:14.775379Z + eslint@8.51.0 2023-10-29T01:42:14.775525Z + eslint-config-next@13.5.6 2023-10-29T01:42:14.775659Z + next-remote-refresh@0.10.0 2023-10-29T01:42:14.775859Z + prettier@3.0.3 2023-10-29T01:42:14.775999Z + textlint@13.3.3 2023-10-29T01:42:14.776161Z + textlint-rule-preset-ja-technical-writing@8.0.0 2023-10-29T01:42:14.776293Z + typescript@4.9.5 2023-10-29T01:42:14.77642Z + @chakra-ui/react@2.8.1 2023-10-29T01:42:14.776596Z + @emotion/react@11.11.1 2023-10-29T01:42:14.776749Z + @emotion/styled@11.11.0 2023-10-29T01:42:14.776889Z + @mdx-js/loader@3.0.0 2023-10-29T01:42:14.777015Z + @mdx-js/react@3.0.0 2023-10-29T01:42:14.777139Z + esbuild@0.19.5 2023-10-29T01:42:14.777265Z + framer-motion@10.16.4 2023-10-29T01:42:14.777412Z + mdx-bundler@9.2.1 2023-10-29T01:42:14.777559Z + next@13.5.6 2023-10-29T01:42:14.777687Z + prism-react-renderer@1.3.5 2023-10-29T01:42:14.777827Z + prismjs@1.29.0 2023-10-29T01:42:14.777952Z + react@18.2.0 2023-10-29T01:42:14.778085Z + react-children-utilities@2.9.0 2023-10-29T01:42:14.778234Z + react-dom@18.2.0 2023-10-29T01:42:14.778363Z + react-icons@4.11.0 2023-10-29T01:42:14.7785Z + react-twitter-embed@4.0.4 2023-10-29T01:42:14.77863Z + react-youtube@10.1.0 2023-10-29T01:42:14.778758Z + remark-breaks@4.0.0 2023-10-29T01:42:14.778892Z + remark-gfm@3.0.1 2023-10-29T01:42:14.77902Z + sass@1.69.5 2023-10-29T01:42:14.779163Z 2023-10-29T01:42:14.779301Z 1013 packages installed [16.91s] 2023-10-29T01:42:14.801698Z Executing user command: bun run build 2023-10-29T01:42:15.142586Z $ next build 2023-10-29T01:42:16.376244Z ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache 2023-10-29T01:42:16.387657Z Attention: Next.js now collects completely anonymous telemetry regarding usage. 2023-10-29T01:42:16.388257Z This information is used to shape Next.js' roadmap and prioritize features. 2023-10-29T01:42:16.388642Z You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL: 2023-10-29T01:42:16.388981Z https://nextjs.org/telemetry 2023-10-29T01:42:16.389282Z 2023-10-29T01:42:16.506568Z Linting and checking validity of types ... 2023-10-29T01:42:24.685393Z Creating an optimized production build ... 2023-10-29T01:42:32.681534Z ✓ Compiled successfully 2023-10-29T01:42:32.683925Z Collecting page data ... 2023-10-29T01:42:35.569905Z Generating static pages (0/20) ... 2023-10-29T01:42:35.599307Z Error: NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted 2023-10-29T01:42:35.599629Z at useRouter (/opt/buildhome/repo/.next/server/chunks/899.js:1:15201) 2023-10-29T01:42:35.599833Z at MyApp (/opt/buildhome/repo/.next/server/chunks/353.js:39:66) 2023-10-29T01:42:35.600001Z at Wc (/opt/buildhome/repo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44) 2023-10-29T01:42:35.600159Z at Zc (/opt/buildhome/repo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253) 2023-10-29T01:42:35.600317Z at Z (/opt/buildhome/repo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89) 2023-10-29T01:42:35.600468Z at Zc (/opt/buildhome/repo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:481) 2023-10-29T01:42:35.600623Z at Z (/opt/buildhome/repo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89) 2023-10-29T01:42:35.600772Z at $c (/opt/buildhome/repo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98) 2023-10-29T01:42:35.600933Z at bd (/opt/buildhome/repo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404) 2023-10-29T01:42:35.601155Z at Z (/opt/buildhome/repo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217) 2023-10-29T01:42:35.601331Z ... (同様のエラーが続く) 2023-10-29T01:42:39.972816Z ✓ Generating static pages (20/20) 2023-10-29T01:42:39.973034Z 2023-10-29T01:42:39.973177Z > Export encountered errors on following paths: 2023-10-29T01:42:39.973381Z / 2023-10-29T01:42:39.973532Z /_error: /404 2023-10-29T01:42:39.973741Z /_error: /500 2023-10-29T01:42:39.973944Z /blog 2023-10-29T01:42:39.97409Z /blog/posts/[slug]: /blog/posts/2018-11-06-hello-hugo 2023-10-29T01:42:39.97429Z /blog/posts/[slug]: /blog/posts/2019-07-15-build-helix-keyboard-kit 2023-10-29T01:42:39.974429Z /blog/posts/[slug]: /blog/posts/2020-06-07-next-js-mdx 2023-10-29T01:42:39.974643Z /blog/posts/[slug]: /blog/posts/2022-05-16-the-3rd-abear-cup 2023-10-29T01:42:39.974778Z /blog/posts/[slug]: /blog/posts/2023-03-20-job-transition 2023-10-29T01:42:39.974917Z /blog/posts/[slug]: /blog/posts/2023-09-18-ghost-text-vim 2023-10-29T01:42:39.975044Z /blog/posts/[slug]: /blog/posts/2023-10-02-arc-browser 2023-10-29T01:42:39.975251Z /blog/posts/[slug]: /blog/posts/2023-10-08-iphone-15-pro 2023-10-29T01:42:39.97545Z /blog/posts/[slug]: /blog/posts/2023-10-15-yarn-v1-to-bun 2023-10-29T01:42:39.975679Z /blog/posts/[slug]: /blog/posts/2023-10-22-atcoder 2023-10-29T01:42:39.975891Z /blog/tags/[tag]: /blog/tags/blog 2023-10-29T01:42:39.976085Z /blog/tags/[tag]: /blog/tags/iidx 2023-10-29T01:42:39.976221Z /blog/tags/[tag]: /blog/tags/keyboard 2023-10-29T01:42:39.976348Z /blog/tags/[tag]: /blog/tags/vim 2023-10-29T01:42:39.976474Z /projects 2023-10-29T01:42:39.976618Z /projects/bms 2023-10-29T01:42:40.029009Z error: script "build" exited with code 1 (SIGHUP) 2023-10-29T01:42:40.032207Z Failed: Error while executing user command. Exited with error code: 1 2023-10-29T01:42:40.043036Z Failed: build command exited with code: 1 2023-10-29T01:42:41.563803Z Failed: error occurred while running build command ```
fohte commented 10 months ago

状況

fohte commented 10 months ago

https://github.com/fohte/fohte.net/pull/113 でいろいろ試したところ、そもそも router を呼び出さないようにしたら解決した。具体的には、router を呼び出しているのは next-remote-refresh なので、それをまるごと消した。 ただ、これをすると MDX を更新したときに hot reload されなくて不便。

fohte commented 10 months ago

113 で router 使わないようにして解決した (根本解決ではないけど)