You're ready to deploy your Antigravity application, and suddenly—an error appears. Sometimes the error message is crystal clear; other times it feels like cryptic nonsense. The difference between a quick fix and hours of debugging often comes down to knowing how to interpret and categorize the error. This guide breaks down the most common deployment and build failures by error type, providing specific diagnostic steps and solutions for each.
The Deploy and Build Error Landscape
Antigravity deployment and build errors generally fall into four categories:
- TypeScript Type Errors – Compilation-time issues with type mismatches or missing type annotations
- Dependency Errors – Package installation failures or version conflicts
- Environment Variable Errors – Missing or misconfigured environment variables in
.envor deployment platform - Platform-Specific Errors – Issues unique to your hosting platform (Vercel, Netlify, Cloudflare Workers, etc.)
Your first task is to identify which category your error belongs to. This immediately narrows down the solution space.
TypeScript Type Errors
Error: "Type 'unknown' is not assignable to type..."
This occurs when you're using a variable without an explicit type annotation, particularly with API responses.
// ❌ Error: Type is not declared
const response = fetch(apiUrl);
const data = response.json(); // Type 'unknown' error
// ✓ Fixed: Explicit type annotation
const response: Response = await fetch(apiUrl);
const data: unknown = await response.json();
if (data && typeof data === 'object') {
const result = data as Record<string, any>;
console.log(result.name);
}Diagnostic steps:
- Find the line number mentioned in the error message
- Add an explicit type annotation to the variable (
: TypeName) - For async operations, ensure
awaitis present - Run the build again:
npm run build
Error: "Cannot find module 'moduleName'"
This means the imported module doesn't exist at the specified path.
// ❌ Error: Incorrect file path or name
import { Component } from './components/Button';
// ✓ Fixed: Verify the exact path and filename
import { Component } from './components/button'; // Linux is case-sensitive
// OR
import Button from './components/Button'; // If it's a default exportChecklist:
- Is the filename case exactly correct? (Linux systems are case-sensitive; Windows/macOS are not)
- Is the relative path accurate? (Count your
../levels) - Does the file actually exist in that location?
Error: "Property 'X' does not exist on type 'Y'"
You're accessing a property that isn't defined on the object's type.
// ❌ Error: Property name misspelled
interface Article {
title: string;
content: string;
}
const article: Article = { title: 'Hello', content: 'World' };
console.log(article.tital); // Property 'tital' doesn't exist
// ✓ Fixed: Correct the property name
console.log(article.title);
// OR expand the type definition
interface Article {
title: string;
content: string;
author?: string; // Optional property
}Two common causes: spelling mistakes or outdated type definitions. If you're working with an API response, verify the API's current schema—its response format may have changed.
Dependency and Package Errors
Error: "npm ERR! ERESOLVE unable to resolve dependency tree"
Multiple packages request different versions of a shared dependency, and npm can't find a compatible resolution.
Solutions (in order of preference):
Option 1: Use the legacy peer deps flag
npm install --legacy-peer-depsThis tells npm to ignore peer dependency conflicts. Solves the issue in most cases.
Option 2: Clear and reinstall
rm package-lock.json
npm installThis deletes cached dependency info and forces npm to recalculate compatible versions.
Option 3: Explicitly specify versions
npm install react@18 react-dom@18 @types/react@18Manually align versions in package.json for known conflicting packages.
Error: "Cannot find module 'next/config' or similar built-in module"
A required package isn't installed or is corrupted.
# Complete reinstall
rm -rf node_modules package-lock.json
npm install
# OR, if using Antigravity CLI
antigravity doctorThe antigravity doctor command checks Node.js version, npm version, and installed packages against requirements.
Error: "ERR! code ENETUNREACH"
Network connectivity issue—npm can't reach the registry.
# Check internet connection
ping registry.npmjs.org
# Clear npm cache
npm cache clean --force
# Reset DNS (macOS/Linux)
sudo dscacheutil -flushcache
# Try install again
npm installIf you're behind a corporate proxy, configure npm to use it:
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080Environment Variable Errors
Error: "process.env.NEXT_PUBLIC_API_URL is undefined"
In Next.js and similar frameworks, environment variables need explicit declaration. Crucially, client-side variables must be prefixed with NEXT_PUBLIC_.
// ❌ Error: Private env var used on client
const apiKey = process.env.API_KEY; // undefined at build time
// ✓ Correct: Public prefix for client-side usage
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
const apiKey = process.env.NEXT_PUBLIC_API_KEY;.env.local setup:
# Public (accessible in browser)
NEXT_PUBLIC_API_URL=https://api.example.com
NEXT_PUBLIC_API_KEY=YOUR_API_KEY
# Private (server-only)
DATABASE_URL=postgresql://user:password@localhost/dbname
SECRET_KEY=your-secret-keyFor production deployment (Vercel example):
Vercel Dashboard → Project Settings → Environment Variables. Add each public and private variable here. Ensure the Environments setting includes where each variable should be available (Production, Preview, Development).
Error: "Cloudflare Workers build failed"
Cloudflare Workers have strict size limits (typically <5MB) and don't support certain Node.js APIs.
// ❌ Error: fs module doesn't exist in Workers
const fs = require('fs');
const file = fs.readFileSync('data.json');
// ✓ Fixed: Process files at build time
// config.js or build.js
const data = require('./data.json');
export default data;For deploying to Cloudflare Workers via Antigravity, see our guide on Cloudflare Workers AI edge apps.
Platform-Specific Errors
Vercel Deployment Failures
Error: "Build failed" (generic)
- Go to Vercel Dashboard → Deployments → [Your Deployment] → Build Logs
- Search for "ERROR" to find the specific issue
- Cross-check with local build:
npm install
npm run buildIf it builds locally but fails on Vercel, the issue is usually environment variable mismatch. Verify that all NEXT_PUBLIC_* variables in .env.local are also in Vercel's Environment Variables settings.
Netlify Deployment Failures
Netlify requires explicit build configuration in netlify.toml:
[build]
command = "npm install --legacy-peer-deps && npm run build"
functions = "netlify/functions"
publish = ".next"
[build.environment]
NODE_VERSION = "18"
NPM_VERSION = "9"Common Netlify errors and fixes:
| Error | Cause | Fix |
|---|---|---|
| "npm command not found" | Node.js not installed on build system | Specify NODE_VERSION in netlify.toml |
| ".next folder not found" | Publish path is incorrect | Verify publish points to build output |
| "Build timeout (15 min limit)" | Build takes too long | Clear npm cache, optimize dependencies |
| "Build succeeded but functions not deployed" | Function folder path wrong | Verify functions path in config |
Cloudflare Workers Build Failures
Common issue: incorrect wrangler.toml structure. The [build] section must come before other top-level fields.
# ❌ Error: build section placed after fields
name = "my-worker"
main = "src/index.ts"
[build]
command = "npm run build"
# ✓ Correct: build section first
[build]
command = "npm run build"
name = "my-worker"
main = "src/index.ts"Also watch for these issues:
# Ensure compatibility format is correct
compatibility_date = "2026-03-30"
# Set environment variables if needed
[env.production]
vars = { ENVIRONMENT = "production" }For more Cloudflare-specific issues, check our deployment failure FAQ.
Pre-Deployment Checklist
Running this checklist before deployment prevents most errors:
Code Quality
- [ ] TypeScript builds without errors (
npm run build) - [ ] No linting errors (
npm run lintif available) - [ ] All environment variables are defined (cross-check against
.env.example) - [ ] No console warnings or errors
- [ ] Code is tested locally (
npm run devand manual testing)
Dependency Health
# Check for outdated packages
npm outdated
# Audit for security vulnerabilities
npm audit
# Verify all dependencies install cleanly
rm -rf node_modules && npm installEnvironment Variable Validation
# Verify required vars exist
required_vars=("NEXT_PUBLIC_API_URL" "DATABASE_URL" "SECRET_KEY")
for var in "${required_vars[@]}"; do
if ! grep -q "^$var=" .env.local; then
echo "Missing: $var"
fi
doneLocal Production Build Test
# Build exactly as production will
npm run build
# Start the production server
npm run start
# Visit http://localhost:3000 and test key featuresLooking back and Next Steps
Antigravity build and deployment errors are almost always fixable with a structured diagnostic approach:
- Read the error message carefully – Look for specific error codes and line numbers
- Categorize the error – TypeScript? Dependency? Environment? Platform-specific?
- Apply the targeted solution – Use the sections above matching your category
- Test locally – Reproduce the error (or success) in your development environment
- Verify deployment settings – Double-check environment variables and configuration files
For more details on common setup issues, see our setup errors FAQ.
If you're still stuck after following these steps, reach out to Antigravity support with your error message, build logs, and the steps you've already tried. They're there to help you succeed.
Recommended Reading
To deepen your understanding of TypeScript, Node.js, and deployment pipelines, consider these books:
Happy deploying!