Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read properties of undefined (reading 'push') in next.js

TypeError: Cannot read properties of undefined (reading 'push') at writeConfigurationDefaults (/home/anonymous/ProjectName/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js:223:30) at async verifyTypeScriptSetup (/home/anonymous/ProjectName/node_modules/next/dist/lib/verifyTypeScriptSetup.js:120:9) at async DevServer.verifyTypeScript (/home/anonymous/ProjectName/node_modules/next/dist/server/dev/next-dev-server.js:648:34) at async DevServer.prepareImpl (/home/anonymous/ProjectName/node_modules/next/dist/server/dev/next-dev-server.js:672:9) at async NextServer.prepare (/home/anonymous/ProjectName/node_modules/next/dist/server/next.js:157:13) at async Server.<anonymous> (/home/anonymous/ProjectName/node_modules/next/dist/server/lib/render-server.js:121:17) { type: 'TypeError' }

  1. update your next.js app to 13.4.1
  2. npm run dev or npm run build
like image 351
khashayar ghajar Avatar asked Oct 28 '25 22:10

khashayar ghajar


1 Answers

TLDR; 0. You probably don't have an include directive in you config.

  1. Back up your tsconfig.json
  2. add an empty "include": [] directive to your tsconfig.json file, and run dev. Next hijacks your file and adds some of its own types to your config.

I found this issue as well today. It seems not having an include directive in your child tsconfig.json file causes this error, which seems like a bug. The logic in writeConfigurationDefaults assumes an include key on the config object exists. What is strange is that the base config does have an include directive but this part of the code for whatever reason has not picked it up so the error occurs.

like image 125
Joe Seifi Avatar answered Oct 31 '25 13:10

Joe Seifi