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.

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. Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com 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. Alvin Voo Alvin Voo I’ve watched the tech landscape evolve over the last decade—from the structured days of Java Server Pages to the current "wild west" of Agentic-driven development. While AI can "vibe" a frontend into existence, I specialize in the architecture that keeps it from collapsing. My expertise lies in the critical backend infrastructure: the parts that must be fast, secure, and scalable. I thrive on high-pressure environments, such as when I had only three weeks to architect and launch an Ethereum redemption system with minimal prior crypto knowledge, turning it into a major revenue stream. What I bring to your project: Forensic Debugging: I don't just "patch" bugs; I use tools like Datadog and Explain Analyzers to map out bottlenecks and resolve root causes—like significantly reducing memory usage by optimizing complex DB joins. Full-Stack Context: Deep experience in Node.js and React, ensuring backends play perfectly with mobile and web teams. Sanity in the Age of AI: I bridge the gap between "best practices" and modern speed, ensuring your project isn't just built fast, but built to last. 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. Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap.

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