Error: Failed to collect page data for

I encountered a strange issue 2-3 days ago. I started receiving the following error:

SyntaxError: Unexpected identifier '#Y'
at wrapSafe (node:internal/modules/cjs/loader:1427:18)
at Module._compile (node:internal/modules/cjs/loader:1449:20)
at Module._extensions..js (node:internal/modules/cjs/loader:1588:10)
at Module.load (node:internal/modules/cjs/loader:1282:32)
at Module._load (node:internal/modules/cjs/loader:1098:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
at Module.require (node:internal/modules/cjs/loader:1304:12)
at mod.require (E:\git\desafio-viajero-visitante\client\node_modules\next\dist\server\require-hook.js:65:28)
at require (node:internal/modules/helpers:123:16)

Error: Failed to collect page data for /api/dashboard/create-company
at E:\git\desafio-viajero-visitante\client\node_modules\next\dist\build\utils.js:1268:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}

The route in question hadn’t been modified in over 21 days, so it seemed unlikely that it was the source of the error. After some debugging, I decided to delete the route and see what happened. This led to errors on other routes, so I continued deleting them. After removing 5 routes, I began to suspect that the issue wasn’t with the routes themselves. I eventually deleted most of them, but the same error persisted on routes that had been in production for over 3 months.

I found some users on Google experiencing the same error, even when starting a new project from scratch with a Next.js template. This made the situation even more puzzling. I then reverted to a commit that was in production 1-2 months ago, but the error remained. Clearly, something external to my app is causing this issue.

Creating a new project isn’t an option since this one has been in production for over 6 months, and I need to deploy new adjustments today. I’ve performed a clean install on all branches and tests, deleted node_modules, and removed package-lock.json.

Does anyone have any idea what might be causing this?

Here’s my package.json:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@hookform/resolvers": "^3.3.4",
    "@nivo/bar": "^0.87.0",
    "@nivo/line": "^0.87.0",
    "@nivo/pie": "^0.87.0",
    "@radix-ui/react-accordion": "^1.2.0",
    "@radix-ui/react-alert-dialog": "^1.0.5",
    "@radix-ui/react-aspect-ratio": "^1.1.0",
    "@radix-ui/react-avatar": "^1.0.4",
    "@radix-ui/react-checkbox": "^1.0.4",
    "@radix-ui/react-dialog": "^1.0.5",
    "@radix-ui/react-dropdown-menu": "^2.0.6",
    "@radix-ui/react-label": "^2.0.2",
    "@radix-ui/react-popover": "^1.0.7",
    "@radix-ui/react-radio-group": "^1.2.0",
    "@radix-ui/react-select": "^2.0.0",
    "@radix-ui/react-separator": "^1.0.3",
    "@radix-ui/react-slot": "^1.0.2",
    "@radix-ui/react-tabs": "^1.0.4",
    "@radix-ui/react-toast": "^1.1.5",
    "@radix-ui/react-tooltip": "^1.1.1",
    "@react-three/fiber": "^8.15.16",
    "@sentry/nextjs": "^8.17.0",
    "@tanstack/react-table": "^8.16.0",
    "@vercel/speed-insights": "^1.0.12",
    "@wojtekmaj/react-hooks": "^1.21.0",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.1",
    "date-fns": "^3.6.0",
    "firebase": "^10.8.1",
    "firebase-admin": "^12.0.0",
    "js-cookie": "^3.0.5",
    "lucide-react": "^0.378.0",
    "multer": "^1.4.5-lts.1",
    "next": "^14.2.3",
    "next-themes": "^0.3.0",
    "nodemailer": "^6.9.13",
    "papaparse": "^5.4.1",
    "react": "^18",
    "react-audio-voice-recorder": "^2.2.0",
    "react-day-picker": "^8.10.1",
    "react-dom": "^18",
    "react-dropzone": "^14.2.3",
    "react-hook-form": "^7.51.4",
    "react-pdf": "^9.1.0",
    "react-player": "^2.16.0",
    "react-qr-code": "^2.0.15",
    "react-record-webcam": "^1.1.5",
    "react-unity-webgl": "^9.5.1",
    "react-webcam": "^7.2.0",
    "sonner": "^1.5.0",
    "tailwind-merge": "^2.3.0",
    "tailwindcss-animate": "^1.0.7",
    "three": "^0.162.0",
    "uuid": "^9.0.1",
    "vaul": "^0.9.1",
    "zod": "^3.23.6"
  },
  "devDependencies": {
    "@eslint/js": "^9.9.0",
    "autoprefixer": "^10.0.1",
    "eslint": "^8.57.0",
    "eslint-config-next": "14.1.0",
    "eslint-plugin-react": "^7.35.0",
    "globals": "^15.9.0",
    "postcss": "^8",
    "tailwindcss": "^3.3.0"
  }
}

Any insights would be greatly appreciated.

Hi @feliprado! Welcome to the Vercel Community :smile:

Thanks for the detailed description. Let’s tackle this strange issue with some quick checks:

  1. Node.js Version: Ensure consistency with an .nvmrc file:
 echo "18.17.0" > .nvmrc  # Replace with your project's Node version

  1. Next.js Version: Try downgrading:
 npm install next@14.1.0npm install next@14.1.0

  1. Babel: Check for custom configs interfering with Next.js.
  2. TypeScript: Verify tsconfig.json compatibility with your Next.js version.
  3. ESLint: Temporarily disable to isolate the issue:
 mv .eslintrc.json .eslintrc.json.bakmv .eslintrc.json .eslintrc.json.bak

  1. Next.js Cache: Clear it:
 rm -rf .nextrm -rf .next

  1. Dependencies: Update all:
 npx npm-check-updates -u && npm installnpx npm-check-updates -u && npm install

  1. File Encoding: Ensure UTF-8 without BOM for all files.
  2. Environment Variables: Review, especially in API routes.
  3. Experimental Flag: Add to package.json scripts:
 "dev": "node --experimental-vm-modules node_modules/next/dist/bin/next dev""dev": "node --experimental-vm-modules node_modules/next/dist/bin/next dev"

(Do the same for “build” and “start” scripts)

If these don’t work, try creating a minimal reproduction.

Good luck, and let us know how it goes!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.