JavaScript “is not a function”: Find What You’re Actually Calling
TypeError: x is not a function means JavaScript resolved the call target, but the runtime value at that call site is not callable. Start with the exact call expression and inspect the receiver/property/value immediately before it. Do not add a guard, rename a method, or change import syntax until you know what value replaced or failed to provide the expected function.
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.First-party reproduction run on Oct 29, 2026 in Node.js v24.22.1: calling a number named formatValue produced “TypeError: formatValue is not a function”; replacing it with formatValue as a function printed “function 42”. For your own failure, inspect the exact call target immediately before the failing line. For object.method(), inspect both the receiver and object.method; an overwritten method or wrong object may need a different fix.
node -e 'const formatValue = 42; formatValue()'
# TypeError: formatValue is not a function
node -e 'const formatValue = value => String(value); console.log(typeof formatValue, formatValue(42))'
# function 42Interpret: typeof ... === "function" means that captured target is callable. Any other value tells you what the runtime is actually trying to call. If the receiver itself is null/undefined in the original expression, classify that property-access failure separately.
Why this happens
This TypeError is about callability at the failing call site. Common causes include the wrong receiver type, a property that is absent or contains data instead of a function, a function name/property overwritten later, API/version mismatch, or an import whose runtime shape differs from what the caller expects. This is later than x is not defined: the name/expression resolved far enough for JavaScript to attempt a call.
Diagnose before changing more
For example, array methods such as
map() are not available on plain objects.A later assignment can replace a function with a string, object or other value.
Default and named imports can produce a different runtime value than your code expects.
JSON, network payloads and structured data do not preserve executable function values. Confirm the caller is not treating data as an object instance/API with methods.
Check the API for the installed version. A removed/renamed method or changed export shape should not be “fixed” with a type guard.
Inspect the runtime import/object shape in the failing build before changing source import syntax or enabling interop workarounds.
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();
}typeof handler === 'function' guard is appropriate only when “no callable handler” is a valid state. If the function is required by the program contract, silently skipping the call hides the defect; fix the producer, receiver, API usage or import instead.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.
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';Verify: Log the imported value once after changing the import. It should have the export shape you expect before you call it.
What not to do
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.
References and related guides
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.
Loading community discussion…
Comments could not load here. Open ErrorHarbor Discussions on GitHub →