By the end of this lesson you will read any error message, find the one line that matters, and hand the AI a clue instead of a panic.
You need: nothing installed; a project that shows an error helps · Time: 8 minutes
A red wall of text looks scary. It is actually the most helpful thing your computer ever says to you: what went wrong and where.
You will meet errors in three places:
- The terminal where your app runs (for example the window where
npm run devis running). - The browser Console, the error list inside Chrome's developer tools (next lesson).
- The build log on your hosting site when you go live (lesson 5).
In When it breaks you learned to paste the exact error into a bug report. This lesson teaches you to read it first, so you can point the AI at the right line and spot when its fix misses.
Why?An error you can read turns "it's broken" into "line 2 of stock.js gets nothing where it expected a list". The AI fixes the second one in one try.
- The terminal where your app runs (for example the window where
Almost every error has the same four parts:
- Type: the kind of problem, like
TypeErrororSyntaxError. - Message: what went wrong, in words.
- Location:
file:line:column.src/stock.js:2:16means filesrc/stock.js, line 2, character 16. - Stack trace: the list of
at ...lines. It is the path the code took to reach the crash, like a trail of footprints.
One error, four parts. Your first own file in the stack is where you start. Why?Once you know the four parts, a 40-line error shrinks to two facts: what kind of problem, and which line of your code.
- Type: the kind of problem, like
You don't need to fix these yourself. Knowing the name tells you what kind of clue it is:
TypeError: the code used something the wrong way. Most often: it expected data, but got nothing (undefinedornull). Example: Cannot read properties of undefined (reading 'items').ReferenceError: the code used a name that does not exist, often a typo. Example: stok is not defined.SyntaxError: the code itself is badly written, like a missing bracket or comma. The app usually can't even start.Cannot find module(JavaScript) orModuleNotFoundError(Python): a file or package is missing, or its name is spelled differently.
undefined means "this has no value yet". null means "empty on purpose". Both cause many
TypeErrors.Match them Match each error type with what it usually means
Tap an item on the left, then its meaning on the right.
Why?The type narrows the search. A
SyntaxErrormeans "look at the last edit"; aTypeErrormeans "find where the data went missing".Here is a real Node.js error from a chai stall stock app. Read it with the notes:
The JavaScript rule is to read top-down, stop at the first line that is your own file. Lines with
node:internalornode_modules(packages you installed) are rarely the cause. Chrome's Console works the same way: the newest call is at the top.Why?The first line of your own code is where your code last touched the problem. Pointing the AI there saves it from reading the whole project.
Python prints the same information in the opposite order. Its header even tells you: most recent call last. So the bottom is where it broke.
KeyError means the code asked for a field that isn't there. Here the tuition fees list has a typo in Ravi's row.
Why?If you read Python top-down like JavaScript, you start at the place furthest from the crash. Bottom first, then go up only if you need more context.
One real problem often causes a pile of errors after it, like one wrong entry that breaks every total below it in Excel. So:
- Fix the first error, then run again. Many of the others usually disappear.
- Red is an error, yellow is a warning. An error stops something. A warning says "this may cause trouble later". Fix errors first; mention warnings only if they look related.
- Copy from the first line of the error to the last, not only the last line.
Here is a starter prompt for when you see an error you don't understand:
Prompt · copy it into your AI agentExplain this error in simple words before changing anything. 1. What type of error is it and what does the message mean? 2. Which file and line in MY code is the most likely starting point? Ignore node_modules and node:internal lines. 3. What are the 2 most likely causes, and how can we check each one? Error (copied from [the terminal where npm run dev runs]): [paste the full error here, first line to last]
Why?Ten errors on screen is often one problem shouting ten times. Fixing the first one is the fastest path to quiet.
- Errors are clues: type, message, location (
file:line:column) and stack trace. TypeError,ReferenceError,SyntaxErrorandCannot find moduleeach point to a different kind of cause.- Read JavaScript top-down and start at the first line from your own files; read Python bottom-up.
- Fix the first error first; red errors before yellow warnings.
- Next: Browser DevTools: Console and Network.
- Errors are clues: type, message, location (
Create a free account to save your progress and open every lesson. Create free account