Cursor integration

Vercel and Netlify Build Errors on Cursor-Generated Projects

Your Cursor-generated project builds and runs perfectly locally with npm run dev, but deploying to Vercel or Netlify fails with build errors. The platform's build log shows module resolution failures, SSR compatibility errors, missing dependencies, or Next.js/Nuxt-specific issues that didn't appear during development.

Vercel and Netlify run production builds in a clean environment, which exposes issues hidden by your local development setup. Hot module replacement (HMR) and development-mode error recovery mask problems that surface in production builds. Additionally, these platforms have specific requirements for server-side rendering, API routes, and static generation that differ from local development servers.

Each failed deploy means another round of pushing a fix and waiting 1-3 minutes for the build to run, making the feedback loop painfully slow compared to local development.

Error Messages You Might See

Build error: Module not found: Can't resolve 'package-name' ReferenceError: window is not defined Error: Failed to collect page data for / Build exceeded maximum allowed duration (45 minutes) Error: Environment variable not found: NEXT_PUBLIC_API_URL Export encountered errors on following paths: /dynamic-page
Build error: Module not found: Can't resolve 'package-name'ReferenceError: window is not definedError: Failed to collect page data for /Build exceeded maximum allowed duration (45 minutes)Error: Environment variable not found: NEXT_PUBLIC_API_URLExport encountered errors on following paths: /dynamic-page

Common Causes

  • Dependencies in devDependencies instead of dependencies — Cursor installed packages as devDependencies that are needed at build time. Vercel/Netlify may not install devDependencies in production builds
  • Server-side code using browser APIs — Cursor generated code that references window, document, or localStorage in components that run during SSR, causing ReferenceError on the server
  • Missing build-time environment variables — Environment variables used during the build (like API URLs, public keys) aren't configured in the Vercel/Netlify dashboard
  • Node.js version mismatch — The platform uses a different Node.js version than your local machine. Cursor may have used syntax or APIs from a newer Node version
  • Dynamic imports not handled for static generation — Pages that use dynamic data are configured for static export but can't be pre-rendered without the data source
  • Monorepo or workspace configuration issues — The platform can't find the correct root directory or build command in a monorepo setup

How to Fix It

  1. Check the build logs carefully — The exact error message and the file/line it points to are your best debugging tools. Most build failures have a specific, fixable cause in the logs
  2. Guard browser API usage — Wrap browser-only code in checks: if (typeof window !== 'undefined') { /* browser code */ } or use Next.js dynamic imports with { ssr: false }
  3. Configure environment variables on the platform — Add all required env vars in the Vercel/Netlify dashboard. For build-time vars in Next.js, prefix with NEXT_PUBLIC_
  4. Pin the Node.js version — Add "engines": { "node": ">=18" } to package.json, or set the NODE_VERSION environment variable on the platform
  5. Run the production build locally first — Execute npm run build locally to catch the same errors before deploying. This replicates what the platform does
  6. Move build-time packages to dependencies — If a package is used during build or SSR, it must be in dependencies, not devDependencies

Real developers can help you.

legrab legrab I'll fill this later Kingsley Omage Kingsley Omage Fullstack software engineer passionate about AI Agents, blockchain, LLMs. Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. AUXLE AUXLE I am a Full Stack Developer experienced in building Websites, Web apps and Cross Platform Mobile Apps for Startups and Companies. Jen Jacobsen Jen Jacobsen I’m a Full-Stack Developer with over 10 years of experience building modern web and mobile applications. I enjoy working across the full product lifecycle — turning ideas into real, well-built products that are intuitive for users and scalable for businesses. I particularly enjoy building mobile apps, modern web platforms, and solving complex technical problems in a way that keeps systems clean, reliable, and easy to maintain. rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help Jacek Rozanski Jacek Rozanski Senior PHP/Symfony developer and DevOps engineer with 20+ years of professional experience, running opcode.pl (web development agency, est. 2004). Day job: I'm the sole backend developer at merketing company where I own and maintain 11 PHP/Symfony microservices on AWS (ECS Fargate, RDS, S3, CloudFront), handle the full CI/CD pipeline (Bitbucket Pipelines, Docker), and manage monitoring with Sentry and CloudWatch. These services handle high request volumes in production every month. What I bring to AI-built apps: - I audit and fix security issues (OWASP methodology), performance bottlenecks, and architectural problems in codebases generated by Cursor, Claude Code, Lovable, Bolt, and v0 - I refactor AI-generated prototypes into production-grade applications with proper error handling, testing, and clean architecture (SOLID, DDD, hexagonal architecture) - I set up the infrastructure AI tools don't touch: AWS hosting, CI/CD pipelines, automated deployments, database optimization, monitoring, and alerting - I integrate external services: payment providers, email systems, partner APIs, SSO/auth Tech stack: PHP 8.x, Symfony, React, Next.js, PostgreSQL, MySQL, Docker, AWS (ECS, RDS, S3, SQS/SNS, CloudFront), Terraform, Supabase. I also use AI tools daily (Claude Code, Cursor) in my own workflow, so I understand both the strengths and the gaps in AI-generated code. Based in Poland (CET timezone). Available for async work and calls during EU/US business hours. Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields Anthony Akpan Anthony Akpan Developer with 8 years of experience building softwares fro startups

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

Why does my app work with npm run dev but fail on Vercel?

npm run dev uses a development server with hot reloading that's more forgiving. The production build (npm run build) runs static analysis, tree shaking, and SSR that expose issues hidden in development. Always test with npm run build locally before deploying.

How do I fix 'window is not defined' on Vercel?

This happens when server-side rendering (SSR) tries to run browser-only code. Wrap browser API usage in if (typeof window !== 'undefined') checks, or use Next.js dynamic() with ssr: false for components that require the browser environment.

Related Cursor Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help