Abdelkadir Bouziane
Abdelkadir Bouziane

Reputation: 51

Error: Failed to collect page data for /dashboard

I use nextjs to build the frontend of my website. I recently added some code (which I'm pretty sure is correct) to my project.

After running npm run build, I got an error that tells me that nextjs failed to collect the data for one of my pages.

> Build error occurred
Error: Failed to collect page data for /dashboard
    at C:\Users\ga_bo\Desktop\my-project\node_modules\next\dist\build\utils.js:916:15 {
  type: 'Error'
}

I recently upgraded the version of node I use from version 16 to version 18. I thought this caused the error, so I deleted the local repository of my project and reinstalled version 16 of node then reclone my project repo and then run npm run build, but the error still occure.

I even tried removing the changes I made to the code and running npm run build, but the error still occurs!!!

I am really confused about this error, please help me if you have any idea what is causing it.

Upvotes: 5

Views: 16198

Answers (3)

ben
ben

Reputation: 480

I was facing a similar issue where I kept getting a that build error. In my case, it turned out that I was mistakenly using .tsx file extensions for my API route files. After switching the file extensions to .ts (since API routes don’t require JSX syntax), the build succeeded.

If you’re using .tsx in your API route files, try renaming them to .ts. This might resolve the issue.

Upvotes: 1

Dima Dorogonov
Dima Dorogonov

Reputation: 2553

I saw this error when my getStaticPaths method was trying to fetch JSON from localhost, but I forgot to run the app.

Upvotes: 1

Axiumin_
Axiumin_

Reputation: 2145

This is an issue related to a new update to the library you're using, react-countup. As mentioned by rhammel-aip on this GitHub issue, you can put this into your package.json for now to fix this issue:

"resolutions": {
    "react-countup/countup.js": "2.5.0"
  },

Upvotes: 0

Related Questions