node type_error ai_generated true

TypeError: callback is not a function

ID: node/typeerror-callback-not-function

Also available as: JSON · Markdown
92%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
20 active

Root Cause

Callback argument is undefined. Common when using promisified API with callback style, or missing argument.

generic

Workarounds

  1. 95% success Check if you're mixing callback and promise APIs — use await or .then() instead
    // Old: fs.readFile(path, callback)
    // New: const data = await fs.promises.readFile(path)

    Sources: https://nodejs.org/api/fs.html#promise-example

  2. 88% success Verify all required arguments are passed — the callback might be a missing middle argument
    Verify all required arguments are passed — the callback might be a missing middle argument

    Sources: https://nodejs.org/api/errors.html#class-typeerror

Dead Ends

Common approaches that don't work:

  1. Add a no-op callback: () => {} 65% fail

    Hides the real issue — the function signature changed

  2. Wrap in try/catch 70% fail

    The error is thrown synchronously before the callback — catch won't help async flow

Error Chain

Frequently confused with: