ErrorBellFree

Error library / this error

How to fix it

ReferenceError: x is not defined

What it means

JavaScript could not find a variable with that name in the current scope.

Common causes

  • A typo, or different capitalization.
  • A missing import.
  • A script that defines the variable failed to load, or loads after the code that uses it.
  • The variable was declared inside a block or function and used outside it.

How to fix it

1. Import or declare it

Check that the name is imported where you use it.

import { formatDate } from './utils';

2. Check the script order

For global scripts, open the Network tab and confirm the file loaded (a 404 here is the usual cause) and that it comes first.

3. Guard optional globals

For third-party snippets that may be blocked by an ad blocker:

if (typeof window.fbq === 'function') window.fbq('track', 'Lead');

Catch it the moment it happens

ErrorBell shows a dot on the page when this error occurs and takes you to the failing line, so you do not have to hunt through the console. Add it to Chrome, it is free.

Related errors