Coding tips
ReferenceError: x is not defined in JavaScript: 10 Causes and Fixes, from Typos and TDZ to require, __dirname and window in Node (Tested Examples)
JavaScript throws ReferenceError: x is not defined when it cannot find a variable with that name in any scope. Here are 10 tested causes in Node.js 24 and Chrome, from typos, block scope and the temporal dead zone to require, __dirname and window in ES modules and Node.