1

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.

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • Is the error provided the complete stack trace from Node? – Axiumin_ May 03 '23 at 14:49
  • Yes, here is the error stack trace : SyntaxError: Unexpected token 'export' at Object.compileFunction (node:vm:360:18) at wrapSafe (node:internal/modules/cjs/loader:1124:15) at Module._compile (node:internal/modules/cjs/loader:1160:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10) at Module.load (node:internal/modules/cjs/loader:1074:32) – Abdelkadir Bouziane May 03 '23 at 15:01
  • at Function.Module._load (node:internal/modules/cjs/loader:909:12) at Module.require (node:internal/modules/cjs/loader:1098:19) at require (node:internal/modules/cjs/helpers:108:18) at Object. (C:\Users\ga_bo\Desktop\my-project\node_modules\react-countup\build\index.js:6:18) at Module._compile (node:internal/modules/cjs/loader:1196:14) – Abdelkadir Bouziane May 03 '23 at 15:01

1 Answers1

0

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"
  },
Axiumin_
  • 2,107
  • 2
  • 15
  • 24