JavaScript TypeError: x is not a function — Check the Value Before Calling It

This error is different from is not defined: JavaScript found a value, but the value you tried to call is not actually a function.

JavaScriptBrowsers · Node.jsLast reviewed Sep 25, 2026
🎯 You’re likely in the right place if:
The console shows TypeError: ... is not a function.The failing code uses parentheses like value() or object.method().The identifier exists, but its runtime value may be a string, object, undefined property or other non-callable value.
Choose the path that matches what you see
typeof value is not “function”Trace where the value was assigned or returned.
object.method is missingVerify the receiver type and the exact method name.
Imported value has the wrong shapeCompare default vs named exports with the module’s real export declaration.
A callback is expectedPass a function, not the result of calling that function or a non-function value.
Difficulty: Easy–ModerateRisk: Low first
🔎 Quick Check — inspect the runtime value before calling it

Log the value and its type immediately before the failing call. This tells you whether the problem is the object, property name, import shape or overwritten variable.

console.log(value, typeof value);

Verify: A callable function reports function. Any other type explains why the call fails.

Did the runtime type explain the failure?
ADSENSE · reserved slot after the first useful step

Why this happens

MDN defines this TypeError as an attempt to call a value that is not a function. Common causes include a typo in a method name, calling a property that does not exist on that object type, or importing a module in a different shape than expected.

Diagnose before changing more

1
Is the method valid for this object type?
For example, array methods such as map() are not available on plain objects.
2
Was the function name overwritten?
A later assignment can replace a function with a string, object or other value.
3
Does the import match the export style?
Default and named imports can produce a different runtime value than your code expects.

Fix #2 — correct the object or method being called

Confirm the receiver has the method you are invoking. If the value should be an array, function or class instance, trace where that value is created and validate its shape before the call.

if (typeof handler === 'function') { handler(); }
🟡 Before changing configuration: A type guard can prevent a crash, but still investigate why the unexpected value arrived.

Verify: Run the same call again. The value immediately before the call should be the expected object/function type, and the original TypeError should be gone.

Did Fix #2 work?

Fix #3 — align import/export shape and avoid name collisions

If the value comes from a module, verify whether it is a default export, named export or namespace object. Also check that a local variable has not reused the function’s name.

// named export export function runTask() {} import { runTask } from './task.js';
🟡 Keep it reversible: Do not change import syntax blindly; match the module’s actual export declaration.

Verify: Log the imported value once after changing the import. It should have the export shape you expect before you call it.

Did Fix #3 work?

What not to do

Do not add optional chaining or a type guard only to hide an unexpected value; use it only when “missing” is a valid state.Do not rename methods by trial and error. Confirm the receiver type and API first.Do not switch default/named import syntax unless it matches the module’s actual exports.

Still seeing the error?

If the value is a function when logged but the error still appears elsewhere, inspect the exact stack trace. A different code path may be calling another property with the same name on a different object.

Before escalating, capture:the exact TypeError and first relevant stack framethe runtime value and typeof result immediately before the callthe receiver/object shape if this is object.method()the module export and import lines if modules are involved

Official references

Still stuck? Ask the community

Share your operating system, software version, exact error text, and which fix you already tried. Another reader may have seen the same setup.

Keep it safe: never post passwords, API keys, access tokens, recovery codes, license keys, private URLs, or confidential logs.
Powered by GitHub DiscussionsSign in with GitHub to comment. Reading comments does not require sign-in.

Loading community discussion…