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.

Yovel Cohen Yovel Cohen I got a lot of experience in building Long-horizon AI Agents in production, Backend apps that scale to millions of users and frontend knowledge as well. Milan Surelia Milan Surelia Milan Surelia is a Mobile App Developer with 5+ years of experience crafting scalable, cross-platform apps at 7Span and Meticha. At 7Span, he engineers feature-rich Flutter apps with smooth performance and modern UI. As the Co-Founder of Meticha, he builds open-source tools and developer-focused products that solve real-world problems. Expertise: 💡 Developing cross-platform apps using Flutter, Dart, and Jetpack Compose for Android, iOS, and Web. 🖋️ Sharing insights through technical writing, blogging, and open-source contributions. 🤝 Collaborating closely with designers, PMs, and developers to build seamless mobile experiences. Notable Achievements: 🎯 Revamped the Vepaar app into Vepaar Store & CRM with a 2x performance boost and smoother UX. 🚀 Launched Compose101 — a Jetpack Compose starter kit to speed up Android development. 🌟 Open source contributions on Github & StackOverflow for Flutter & Dart 🎖️ Worked on improving app performance and user experience with smart solutions. Milan is always happy to connect, work on new ideas, and explore the latest in technology. PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too legrab legrab I'll fill this later Matthew Butler Matthew Butler Systems Development Engineer @ Amazon Web Services Anthony Akpan Anthony Akpan Developer with 8 years of experience building softwares fro startups prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields 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 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.

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