JavaScript and Node.js errors include the familiar browser-side TypeError, ReferenceError, and SyntaxError, plus a whole set of system-level error codes unique to Node.js. Each entry below covers the error with practical fixes and code examples.

Error Codes

ErrorDescriptionFix
TypeErrorCannot read properties of undefined, or calling a non-functionAdd null checks, use optional chaining (?.), and validate data before access
ReferenceErrorVariable is not defined — using an undeclared variableCheck variable declarations, respect let/const block scope, and avoid the Temporal Dead Zone
SyntaxErrorUnexpected token — parse-time mistake in brackets, quotes, or syntaxReview the reported line, check for missing brackets, trailing commas, and invalid characters
ENOENT (No Such File or Directory)File not found at runtime in Node.jsCheck file paths, use path.join(), handle __dirname, and verify the file exists
CORS ErrorBlocked by CORS policy — cross-origin request rejected by serverConfigure Access-Control-Allow-Origin headers on the server, or use a proxy for development

Quick Debug

// Catch all unhandled errors (Node.js)
process.on('uncaughtException', (err) => {
  console.error('Uncaught Exception:', err);
});

process.on('unhandledRejection', (reason) => {
  console.error('Unhandled Rejection:', reason);
});