最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - Nextjs 15.2.2 Crashing on Fresh Install - Stack Overflow

programmeradmin5浏览0评论

Problem

I installed Nextjs using npx create-next-app@latest from Nextjs's website. I pasted the command into my terminal and got a font error. Then, after using GPT-4o and Perplexity to troubleshoot it was solved then, I landed on the infamous issue I've been dealing with for nearly a year (Is anyones Nextjs application breaking because of useReducer?).

Only now the error has a new or different name. Cannot read properties of undefined (reading 'deploymentId). I have yet to see the DeploymentId show up on Stackoverflow

My Setup

Please let me show you what I've used in this blank project

Software

  • Latest Stable OS
  • Vscode (latest),
  • React 19.0.0,
  • Nextjs 15.2.2,
  • Node v22.14.0,
  • NPM v10.9.2

Files

layout.tsx

The layout page and page.tsx is hardly touched. I only fixed that font issue using AI. Here is a screenshot of that code.

package.json

This is a blank site with no content. However, I did use Copilot to notice that the font library "geist" wasn't installed (because of the initial error), so I installed that.

globals.css

Because I had a font error (and fixed it), I want ya'll to still see what I changed to determine if what I did was the cause

next.config.ts

This file had the biggest change because the moment I loaded the new project and ran it. I got the following error:

/usr/local/lib/node_modules/next/dist/server/config.js:786
            throw new Error(`Configuring Next.js via '${(0, _path.basename)(nonJsPath)}' is not supported. Please replace the file with 'next.config.js' or 'next.config.mjs'.`);
                  ^

Error: Configuring Next.js via 'next.config.ts' is not supported. Please replace the file with 'next.config.js' or 'next.config.mjs'.
    at loadConfig (/usr/local/lib/node_modules/next/dist/server/config.js:786:19)
    at async nextDev (/usr/local/lib/node_modules/next/dist/cli/next-dev.js:197:14)
    at async main (/usr/local/lib/node_modules/next/dist/bin/next:155:5)

So I changed this file to mjs and used AI to tweak the code to look like this:

This led to no syntax or importing errors.

Online Tools

  • Perplexity,
  • GPT-4o (Copilot),

What I did

  1. Used npx create-next-app@latest
  2. Went through standard configuration like; Typescript, Tailwindcss, no ESlint (because it sucks), and all "recommended" options.
  3. Used npm run dev
  4. Got a permissions error (because of Apple's intense restrictions), so I used ```sudo npm run dev for the rest of the project
  5. I got a config error and had to change the file from typescript to javascript or mjs.
  6. I got the font error, used AI for assistance, and probably solved that (I got no more errors from that).
  7. After that I got a bunch of cache or yellow errors in my terminal and then I got the TypeError message.
  8. Deleted node_modules and .next and ran everything. Nothing new.
  9. Download the node and npm versions you saw in my setup. Nothing new.
  10. After AI not produce the best results, I went to the internet and read about similar issues occurring. They ended up being similar problems with DIFFERENT UNDERTERMINED solutions. Like in the Dev.to article 'How to avoid the infamous cannot read properties of undefined error with typescript 181h', Fabio (the author), suggested using "strictNullChecks": true within the tsconfig.json. One issue is that; this doesn't apply to my case as Nextjs is not a blank typescript project. Another issue with Fabio's article is the solutions. Fabio manually changes the code to ensure you're not dealing with undefined data types. How could I possibly remember or actively implement this solution every single time I make a brand new Nextjs project?! I'd rather use Flask at that point.
  11. I check this platform. I've found questions asking similar things but I did not find a clear answer to my issue. The TypeError problem existed, but it was the reading thing that was different and the solutions have specific solutions that often required manual changes to your codebase. In which I did not have a codebase because I'm starting fresh.
  12. I checked r/Nextjs and I found promising posts. I obviously know about the general error (from my other StackOverflow Question), but I am not asking about it. It is the specific deploymentId error that isn't anywhere in my project. I know because I searched each file for that Id except; node_modules and .next.

This is about it. Between each step, I've restarted my server. I've also restarted my laptop in the past before and that didn't budge.

Questions

I understand that not many will be able to answer my questions, so I hope you guys will understand my situation more by being a part of my thought process when reading my questions.

  1. Why does this issue persist after every server restart?
  2. What could I be doing wrong that caused this error?
  3. Is this a human error or a software bug to cause the TypeError for deploymentId?
  4. Why is this problem showing up in Nextjs's latest version?
  5. Any sources I missed in researching this issue?

Conclusion

I've come across a similar error like this before from my own experience and nobody has yet to solve it on this platform AND Reddit. Yes, there are promising posts where the commenters are up to something good. It's just not good enough and now this post will add to the dog pile of more Nextjs problems, only now occurring in the latest version.

I hope I've given you adequate info about my problem to assist you in your endeavours and outlines how I got to this issue so it is easy for you to replicate. Please let me know if I've missed something in my thought process. Thank you so much for reading this post. Hopefully, there's progress.

发布评论

评论列表(0)

  1. 暂无评论