Closed23

任意パッケージを入れるとnpm run buildが通らない

ピン留めされたアイテム
BonyChopsBonyChops

結論

任意パッケージのインストール完了時にNext.js自身が.next内を書き換え、それの内容がよろしくないゆえにビルドが失敗するっぽい。
一度発生すると別バージョンにしても呪いが続くので、rm -rf out .next node_modulesで直せる。
Next.js v14.1.0で発生しているバグなので、それ以前(stableであれば14.0.4, canaryであれば14.0.5-canary.68)を使用すれば良い

  • npm i next@14.0.4
  • npm i next@14.0.5-canary.68

バージョン

Next.js バグの有無(❌: バグ)
13.5.5
14.0.1
14.0.2
14.0.4
14.0.5-canary.0 - 14.0.5-canary.68
14.1.0

※14.0.5-canary.0 - 14.0.5-canary.68は、一度バグが発生するコードが含まれた場合、以降のバージョンでも発生するという仮定のもと二分探索で検証

BonyChopsBonyChops
  • Next.js v14.2.0-canary.41
    • Next.jsのバージョンが原因かとおもっていじった産物
  • 元のソースをいじらずにnpm i next-themesをするとなぜがビルドが通らなくなる
  • その後npm remove next-themes && npm run buildはおろか、rm -r out node_modules .next && npm i && npm run buildをしても通らない
  • rm -r fontsをすると通るようになる(要検証)
  • MacBook Air M1 (arm64)

https://github.com/BonyChops/portfolio-v3

追記

元のタイトルはnext-themesを入れるとnpm run buildが通らないでしたが、どうやらnext-themesだけでなくどのパッケージでもこうなるようなのでタイトルを任意パッケージを入れるとnpm run buildが通らないに変更しました。

BonyChopsBonyChops

うまくいくとき

❯ npm i && npm run build

added 715 packages, and audited 716 packages in 18s

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

> portfolio-v3@0.1.0 build
> ts-node scripts/fetchFonts.ts && next build

   ▲ Next.js 14.2.0-canary.41
   - Environments: .env.local

   Creating an optimized production build ...
 ✓ Compiled successfully

./src/Components/SocialButton.tsx
46:18  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
46:18  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text

./src/app/posts/[slug]/page.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/default.tsx
50:7  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/post.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
 ✓ Generating static pages (22/22) 
 ✓ Collecting build traces    
 ✓ Finalizing page optimization    

Route (app)                              Size     First Load JS
┌ ○ /                                    25.5 kB         125 kB
├ ○ /_not-found                          871 B          87.3 kB
├ ○ /apple-icon.png                      0 B                0 B
├ ○ /icon.png                            0 B                0 B
├ ● /posts/[slug]                        4.6 kB         96.1 kB
├   ├ /posts/apt
├   ├ /posts/arai
├   ├ /posts/covidiffuser
├   └ [+10 more paths]
├ ○ /socials                             461 B           100 kB
└ ○ /works                               445 B          95.2 kB
+ First Load JS shared by all            86.4 kB
  ├ chunks/23-c2c600e84e33f03b.js        30.9 kB
  ├ chunks/fd9d1056-9b32e80441d60ad7.js  53.6 kB
  └ other shared chunks (total)          1.9 kB


○  (Static)  prerendered as static content
●  (SSG)     prerendered as static HTML (uses getStaticProps)
BonyChopsBonyChops

失敗する時

❯ npm run build

> portfolio-v3@0.1.0 build
> ts-node scripts/fetchFonts.ts && next build

   ▲ Next.js 14.2.0-canary.41
   - Environments: .env.local

   Creating an optimized production build ...
 ✓ Compiled successfully

./src/Components/SocialButton.tsx
46:18  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
46:18  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text

./src/app/posts/[slug]/page.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/default.tsx
50:7  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/post.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
   Generating static pages (5/22)  [=   ]TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9) {
  digest: '1227601641'
}
TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)
 ✓ Generating static pages (22/22) 

> Export encountered errors on following paths:
        /page: /
Hidden comment
BonyChopsBonyChops

やはりnpm remove next-themesではだめっぽい

❯ npm i next-themes && npm remove next-themes && npm run build

added 1 package, and audited 717 packages in 933ms

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

removed 1 package, and audited 716 packages in 778ms

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

> portfolio-v3@0.1.0 build
> ts-node scripts/fetchFonts.ts && next build

   ▲ Next.js 14.2.0-canary.41
   - Environments: .env.local

   Creating an optimized production build ...
 ✓ Compiled successfully

./src/Components/SocialButton.tsx
46:18  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
46:18  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text

./src/app/posts/[slug]/page.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/default.tsx
50:7  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/post.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
   Generating static pages (3/22)  [=   ]TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582) {
  digest: '3566395810'
}
TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)
 ✓ Generating static pages (22/22) 

> Export encountered errors on following paths:
        /page: /
BonyChopsBonyChops

解せないのはnode_modules .nextを消してもだめなところなんよなあ
gitで追ってない部分で何かが起きてる

❯ npm i next-themes && npm remove next-themes && rm -r node_modules .next && npm i  && npm run build

added 716 packages, and audited 717 packages in 19s

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

removed 1 package, and audited 716 packages in 812ms

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

added 715 packages, and audited 716 packages in 18s

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

> portfolio-v3@0.1.0 build
> ts-node scripts/fetchFonts.ts && next build

   ▲ Next.js 14.2.0-canary.41
   - Environments: .env.local

   Creating an optimized production build ...
 ✓ Compiled successfully

./src/Components/SocialButton.tsx
46:18  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
46:18  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text

./src/app/posts/[slug]/page.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/default.tsx
50:7  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/post.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
   Generating static pages (4/22)  [=   ]TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9) {
  digest: '1227601641'
}
TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)
 ✓ Generating static pages (22/22) 

> Export encountered errors on following paths:
        /page: /
BonyChopsBonyChops

next-env.d.ts消したら通った!

npm i next-themes && npm remove next-themes && rm -r node_modules .next next-env.d.ts  && npm i  && npm run build

added 1 package, and audited 717 packages in 1s

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

removed 1 package, and audited 716 packages in 773ms

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

added 715 packages, and audited 716 packages in 18s

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

> portfolio-v3@0.1.0 build
> ts-node scripts/fetchFonts.ts && next build

   ▲ Next.js 14.2.0-canary.41
   - Environments: .env.local

   Creating an optimized production build ...
 ✓ Compiled successfully

./src/Components/SocialButton.tsx
46:18  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
46:18  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text

./src/app/posts/[slug]/page.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/default.tsx
50:7  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/post.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
 ✓ Generating static pages (22/22) 
 ✓ Collecting build traces    
 ✓ Finalizing page optimization    

Route (app)                              Size     First Load JS
┌ ○ /                                    25.5 kB         125 kB
├ ○ /_not-found                          871 B          87.3 kB
├ ○ /apple-icon.png                      0 B                0 B
├ ○ /icon.png                            0 B                0 B
├ ● /posts/[slug]                        4.6 kB         96.1 kB
├   ├ /posts/apt
├   ├ /posts/arai
├   ├ /posts/covidiffuser
├   └ [+10 more paths]
├ ○ /socials                             461 B           100 kB
└ ○ /works                               445 B          95.2 kB
+ First Load JS shared by all            86.4 kB
  ├ chunks/23-c2c600e84e33f03b.js        30.9 kB
  ├ chunks/fd9d1056-9b32e80441d60ad7.js  53.6 kB
  └ other shared chunks (total)          1.9 kB


○  (Static)  prerendered as static content
●  (SSG)     prerendered as static HTML (uses getStaticProps)
BonyChopsBonyChops

どうやら上記の通り消さないとうまく行かない(next-env.d.tsだけでもだめ)
どういうことだ...??

Hidden comment
Hidden comment
Hidden comment
Hidden comment
BonyChopsBonyChops
  • out
  • next-env.d.ts

上記のどっちかを消せばいけるっぽいけど、単純にこれnext-env.d.tsがない場合はoutを初期化してくれてるだけっぽくないか?
単純にoutを消せという話っぽい

BonyChopsBonyChops

完全に勘違いしてた。どうやらどのパッケージを入れてもこうなるっぽい

❯ npm i is-odd

added 2 packages, and audited 718 packages in 2s

268 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.
❯ npm run build

> portfolio-v3@0.1.0 build
> ts-node scripts/fetchFonts.ts && next build

   ▲ Next.js 14.2.0-canary.41
   - Environments: .env.local

   Creating an optimized production build ...
 ✓ Compiled successfully

./src/Components/SocialButton.tsx
46:18  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
46:18  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text

./src/app/posts/[slug]/page.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/default.tsx
50:7  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./src/lib/post.tsx
90:9  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
   Generating static pages (4/22)  [=   ]TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9) {
  digest: '1227601641'
}
TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'call')
    at Object.t [as require] (/Users/bonychops/portfolio-v3/.next/server/webpack-runtime.js:1:128)
    at require (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18128)
    at I (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
    at /Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
    at F._fromJSON (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106)
    at JSON.parse (<anonymous>)
    at O (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
    at t (/Users/bonychops/portfolio-v3/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:100582)
 ✓ Generating static pages (22/22) 

> Export encountered errors on following paths:
        /page: /
BonyChopsBonyChops

どうやらnext@14.2.0-canary.41のバグだった可能性が高い模様
13.5.5だと直りました

BonyChopsBonyChops
Next.js バグの有無(❌: バグ)
13.5.5
14.0.1
14.0.2
14.0.4
14.0.5-canary.0 - 14.0.5-canary.68
14.1.0

※14.0.4と14.1.0の間のcanary releaseは以下スレで検証

BonyChopsBonyChops

二分探索で14.0.4と14.1.0の間のパッケージを試して原因のバージョンを特定する
versions.txtは次スレ

search.go

package main

import (
	_ "embed"
	"fmt"
	"io"
	"os/exec"
	"sort"
	"strings"
)

//go:embed versions.txt
var versionsTxt string

func test(version string) bool {
	cmdString := fmt.Sprintf("npm i next@%s && rm -r out node_modules .next; npm remove next-themes  && npm i next-themes && npm run build", version)
	fmt.Printf("❯ %s\n", cmdString)
	cmd := exec.Command("zsh", "-c", cmdString)
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		panic(err)
	}
	if err := cmd.Start(); err != nil {
		panic(err)
	}
	buff := make([]byte, 1024)
	n, err := stdout.Read(buff)

	// EOFの場合は err == io.EOF となる
	for err == nil || err != io.EOF {
		// データがGET出来た場合、文字列に変換して表示
		if n > 0 {
			fmt.Print(string(buff[:n]))
		}

		// 再び読み込む
		n, err = stdout.Read(buff)
	}

	if err := cmd.Wait(); err != nil {
		if exiterr, ok := err.(*exec.ExitError); ok {
			return exiterr.ExitCode() == 1
		} else {
			panic(err)
		}
	}

	panic("unexpected")
}

func main() {
	versions := strings.Split(versionsTxt, "\n")
	r := sort.Search(len(versions), func(i int) bool {
		return test(versions[i])
	})
	fmt.Println(r)
	fmt.Println(versions[r])
}

Hidden comment
BonyChopsBonyChops
...
info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
   Collecting page data ...
   Generating static pages (0/22) ...
   Generating static pages (5/22) 
   Generating static pages (10/22) 
   Generating static pages (16/22) 
 ✓ Generating static pages (22/22) 
0
14.0.5-canary.68

...14.1.0の一つ前ってこと?
二分探索いらんやん

このスクラップは2024/03/25にクローズされました