Explain JavaScript TypeErrors

Paste a JavaScript TypeError, such as "Cannot read properties of undefined", and Vibe explains it in plain English: which value was undefined, which line of your code tried to read it and which calls led there.

typeerror.txt

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe12 lines selected

Press Explain it for the sample, or paste your own code first.

What this JavaScript TypeError sample shows

the message
TypeError: Cannot read properties of undefined (reading 'cost') means the code asked for .cost on a value that was undefined. The name in parentheses is the property it tried to read, not the thing that was missing. The first line of the error, file:///home/sam/shop/report.js:8, names the file and line, and Node.js ended the run with exit code 1.
which value was undefined
The ^ sits under the c of cost, and the top at line says the same with report.js:8:33: line 8, column 33. The undefined value is the part right before it, order.shipping. In orders.json, order A2 has "shipping_cost": 6 and no shipping object, so the run stopped at A2: A1 had already printed A1 29.50, and A3 was never reached.
the stack
The at lines start at the line that failed and go back through the calls: orderTotal at line 8 was called by report at line 14, which was called from line 21. That last entry has no function name because line 21, report(orders);, is at the top level of the file. Each entry ends in line and column.
null vs undefined
With "shipping": null for A2 instead of no shipping key, the same line failed with TypeError: Cannot read properties of null (reading 'cost'): same caret, same stack, one word changed. That word tells you which case you have: null when the reply had the key with no value, undefined when the key wasn't there.

Good to know

  • Run with Node.js 25.7.0 on Linux in a test folder mounted at /home/sam/shop, which is why the paths start with file:///home/sam/shop. On your computer they show where your own file is.
  • A1 29.50 came before the error, and output from before a crash stays on screen. The error and the stack go to stderr: with 2>/dev/null only A1 29.50 was left, and with >/dev/null only the error block. Both runs ended with exit code 1.

Before you trust it: ?. stops the crash, not the problem. Adding order.shipping?.cost to the item total printed A2 NaN and then revenue NaN, with exit code 0. order.shipping?.cost ?? 0 printed A2 18.00 and revenue 72.00 without a word, leaving out A2's "shipping_cost": 6. A check that skips and reports the order printed skipped A2: no shipping object in the reply and revenue 54.00.

Explain JavaScript TypeErrors beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).

Install on Mac

curl -fsSL https://unvibe.site/install.sh | bash

Paste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.

No install warning? Use Unvibe in your browser

Opening the .dmg the first time
  1. Open the .dmg and drag Unvibe to Applications.
  2. Open it once; macOS says it can't verify it. Click Done, not the blue Move to Trash.
    macOS dialog: “Unvibe” Not Opened, with a blue Move to Trash button on top and Done under it
    Real screen, macOS 26. On macOS 15 the two buttons sit side by side.
  3. System Settings › Privacy & Security, scroll down to Security, then press Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.
    macOS Privacy & Security, Security section: Unvibe was blocked to protect your Mac, with the Open Anyway button
    Real screen, macOS 15

The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open