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.

zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. 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. Matt Butler Matt Butler Software Engineer @ AWS Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert Basel Issmail Basel Issmail ’m a Senior Full-Stack Developer and Tech Lead with experience designing and building scalable web platforms. I work across the full development lifecycle, from translating business requirements into technical architecture to delivering reliable production systems. My work focuses on modern web technologies, including TypeScript, Angular, Node.js, and cloud-based architectures. I enjoy solving complex technical problems and helping teams turn product ideas and prototypes into working platforms that can grow and scale. In addition to development, I often collaborate closely with product managers, business analysts, designers, and QA teams to ensure that solutions align with both technical and business goals. I enjoy working with startups and product teams where I can contribute both as a hands-on engineer and as a technical partner in designing and delivering impactful software. Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Stanislav Prigodich Stanislav Prigodich 15+ years building iOS and web apps at startups and enterprise companies. I want to use that experience to help builders ship real products - when something breaks, I'm here to fix it.

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