Error fixes
48 guides to the error messages developers hit every day. Each one quotes the exact error, gives a quick-fix checklist, explains why it happens, walks through the fix and shows how to verify it.
JavaScript errors
- TypeError: Cannot Read Properties of Undefined in JavaScript
Fix TypeError: Cannot read properties of undefined by finding which value is missing, reading the stack trace and repairing the data flow.
- TypeError: x Is Not a Function in JavaScript: Causes and Fixes
Fix TypeError: x is not a function in JavaScript: wrong imports, shadowed names, lost this, a missing semicolon or .map on a non-array.
- ReferenceError: x Is Not Defined vs undefined in JavaScript
Fix ReferenceError: x is not defined: typos, block scope, the TDZ, window or require missing in Node, and scripts that load in the wrong order.
- Fixing 'Blocked by CORS Policy' Errors in JavaScript fetch
Fix 'blocked by CORS policy' fetch errors: which headers the server must send, preflights, credentials, dev proxies and why no-cors fails.
- SyntaxError: Unexpected Token '<' in JSON: Debugging fetch
Fix SyntaxError: Unexpected token '<' in JSON from fetch: the server sent HTML. Check res.ok and content-type, then read the body as text.
- Uncaught (in promise): Fixing Unhandled Promise Rejections
Fix Uncaught (in promise) errors and Node crashes from unhandled rejections: missing await, async forEach, fire-and-forget and rethrown errors.
- RangeError: Maximum Call Stack Size Exceeded in JavaScript
Fix RangeError: Maximum call stack size exceeded: missing base cases, self-calling setters, circular data, huge spreads and deep recursion.
- Cannot Use Import Statement Outside a Module: ESM vs CommonJS
Fix SyntaxError: Cannot use import statement outside a module in Node and browsers: type module, .mjs, require of ESM and __dirname in ESM.
More on JavaScript: JavaScript interview questions
Spring Boot errors
- Spring Boot: Failed to Configure a DataSource ('url' Not Specified)
Fix 'Failed to configure a DataSource: url attribute is not specified' in Spring Boot 3 by setting the URL, adding the driver or a profile.
- Whitelabel Error Page 404 in Spring Boot: How to Fix It
Seeing the Whitelabel Error Page with status 404 in Spring Boot 3? Check the mapping, component scan, @RestController and context path.
- Spring Boot Circular Dependency: 'Beans Form a Cycle' Fix
Fix 'the dependencies of some of the beans in the application context form a cycle' in Spring Boot 3 by redesigning beans, not flags.
- Spring Boot: No Qualifying Bean of Type (Could Not Be Found)
Fix 'required a bean of type that could not be found' and 'No qualifying bean' in Spring Boot 3: scanning, conditions, qualifiers, tests.
- Web Server Failed to Start: Port 8080 Was Already in Use
Fix 'Web server failed to start. Port 8080 was already in use' in Spring Boot: find the process on the port, stop it or change server.port.
- Configuring CORS in Spring Boot: Fixing 'Blocked by CORS Policy'
Fix 'blocked by CORS policy' for a Spring Boot 3 API: global CORS config, Spring Security preflight handling, credentials and exposed headers.
- Jackson Infinite Recursion with JPA Entities in Spring Boot
Fix 'Could not write JSON: Infinite recursion (StackOverflowError)' for bidirectional JPA entities in Spring Boot 3 with DTOs or annotations.
- Spring @Autowired Field Is Null: Why Injection Didn't Happen
Why is an @Autowired or @Value field null in Spring Boot? Objects built with new, static fields and constructor timing, and how to fix them.
More on Spring Boot: Spring Boot interview questions
Java errors
- Java NullPointerException: Reading the Message and Fixing the Cause
Fix java.lang.NullPointerException by reading the helpful message, finding the null in the top stack frame and validating inputs early.
- Java ConcurrentModificationException: Removing Items Safely
Fix java.util.ConcurrentModificationException when removing items in a loop: use removeIf or Iterator.remove, and see when concurrent lists help.
- java.lang.OutOfMemoryError: Java Heap Space: Diagnosis and Fixes
Fix java.lang.OutOfMemoryError: Java heap space by checking -Xmx, capturing a heap dump and finding what retains memory in Eclipse MAT.
- ClassNotFoundException vs NoClassDefFoundError in Java
ClassNotFoundException vs NoClassDefFoundError in Java: what each error means, why classes go missing at runtime and how to fix the classpath.
- UnsupportedClassVersionError: Class File Version Mismatch in Java
Fix UnsupportedClassVersionError (class file version 65.0 vs 61.0) by matching the runtime JDK to your build or compiling with javac --release.
- UnsupportedOperationException from Arrays.asList and List.of
Why Arrays.asList and List.of throw UnsupportedOperationException on add or remove, and how to choose a mutable copy or an immutable list.
More on Java: Java interview questions
React errors
- Too Many Re-renders. React Limits the Number of Renders: How to Fix
Fix 'Too many re-renders' in React: a state setter runs during render, often onClick={setX(1)} or state synced in the component body.
- Objects Are Not Valid as a React Child: Causes and Fixes in React
Fix 'Objects are not valid as a React child' in React: rendering objects, Dates, Errors or props, plus async components on the client.
- React Invalid Hook Call: Hooks Can Only Be Called Inside a Component
Fix 'Invalid hook call' in React: hooks in class components, callbacks or plain functions, duplicate React copies and mismatched react-dom.
- React: Cannot Update a Component While Rendering a Different One
Fix the React warning 'Cannot update a component while rendering a different component': a child sets parent state during render.
- Maximum Update Depth Exceeded in React: Causes and Fixes
Fix 'Maximum update depth exceeded' in React: effects with no or unstable dependencies, setState in componentDidUpdate and ref callbacks.
- React State Not Updating Immediately After setState: How to Fix
Why React state isn't updated immediately after setState: render snapshots, batching, functional updaters, mutation and when to use useEffect.
More on React: React interview questions
TypeScript errors
- TS2532: Object Is Possibly 'undefined' (and TS18048) in TypeScript
Fix TS2532 'Object is possibly undefined' and TS18048 by finding where undefined enters the type, then narrowing or failing early.
- TS2322: Type 'X' Is Not Assignable to Type 'Y' in TypeScript
Fix TS2322 'Type X is not assignable to type Y' by reading the elaboration chain from the bottom and correcting the value, not casting.
- TS2339: Property 'x' Does Not Exist on Type 'Y' in TypeScript
Fix TS2339 'Property does not exist on type' for unions, empty objects, DOM elements and window globals without casting to any.
- TS2307: Cannot Find Module or Its Type Declarations in TypeScript
Fix TS2307 'Cannot find module or its corresponding type declarations' and TS7016 by tracing module resolution, @types, paths and exports.
- TypeScript TS2345: Not Assignable to Parameter of Type 'never'
Fix TS2345 'Argument of type string is not assignable to parameter of type never' from empty arrays, function unions and exhaustive checks.
- TS7053: Element Implicitly Has an 'any' Type in TypeScript
Fix TS7053 'Element implicitly has an any type because expression of type string can't be used to index type' with keyof, Record and guards.
More on TypeScript: TypeScript interview questions
Angular errors
- ExpressionChangedAfterItHasBeenCheckedError in Angular (NG0100)
Fix Angular NG0100 ExpressionChangedAfterItHasBeenCheckedError: why the dev-mode check fires, and data-flow fixes that beat setTimeout.
- NullInjectorError: No provider for X! in Angular (NG0201): How to Fix
Fix Angular NullInjectorError: No provider for X! (NG0201): read the injector path, add provideHttpClient(), providedIn root or a token.
- Can't bind to 'ngModel' since it isn't a known property of 'input' in Angular
Fix Angular NG8002 Can't bind to 'ngModel' since it isn't a known property of 'input': import FormsModule, then fix formControl and inputs.
- 'app-x' is not a known element in Angular (NG8001): How to Fix It
Fix Angular NG8001 'app-x' is not a known element: standalone imports, selector typos, NgModule exports, schemas and TestBed setup.
- Angular 'Blocked by CORS Policy' on ng serve: Fix with proxy.conf.json
Fix 'blocked by CORS policy' errors when Angular ng serve calls a backend: proxy.conf.json, angular.json wiring and production CORS setup.
More on Angular: Angular interview questions
Node.js errors
- Error: listen EADDRINUSE: address already in use in Node.js
Fix Node.js 'listen EADDRINUSE: address already in use :::3000': find the process holding the port, close servers on restart, use PORT and port 0.
- npm error code ERESOLVE: Unable to Resolve Dependency Tree
Fix npm 'code ERESOLVE unable to resolve dependency tree': read the peer conflict report, upgrade the right package, use overrides with care.
- npm error code EACCES: Permission Denied on npm install -g
Fix 'npm error code EACCES permission denied' on global installs without sudo: change the npm prefix, use nvm or fnm, prefer npx, fix Docker.
More on Node.js: Node.js interview questions
Git & CI/CD errors
- Git fatal: refusing to merge unrelated histories (How to Fix)
Fix Git's fatal: refusing to merge unrelated histories: why it happens, when --allow-unrelated-histories is right, and safer alternatives.
- Git: failed to push some refs (fetch first, non-fast-forward)
Fix Git's error: failed to push some refs and ! [rejected] main -> main (fetch first): fetch, rebase or merge, and force-with-lease safely.
- Git: Your branch and 'origin/main' have diverged (Fix)
Fix 'Your branch and origin/main have diverged' and fatal: Need to specify how to reconcile divergent branches: merge, rebase or ff-only.
More on Git & CI/CD: Git & CI/CD interview questions
Docker errors
- Docker 'Bind for 0.0.0.0:8080 failed: port is already allocated' Fix
Fix Docker 'port is already allocated' and 'address already in use': find the container or process on the port, then remap or bind to 127.0.0.1.
- Docker 'exec format error': When the Image CPU Does Not Match
Fix 'exec format error' in Docker: confirm the CPU architecture mismatch with uname and docker inspect, then rebuild with the right --platform or buildx target.
More on Docker: Docker interview questions
SQL & PostgreSQL errors
- PostgreSQL 'operator does not exist': Fixing Type Mismatches
Fix PostgreSQL 'operator does not exist: integer = text': read the operand types, cast the constant or parameter, and fix the column type at the source.
More on SQL & PostgreSQL: SQL & PostgreSQL interview questions