Engineering Tools for AI

程式設計

錯誤訊息閱讀指南

學習從錯誤 log 找出真正原因、檔案位置、警告與失敗差異,以及精準提出除錯請求。

31 個項目

訊息結構

First error line

First error line

TypeError: Cannot read properties of undefined

意思

The first clear error line is often the best starting point.

閱讀方式

Ignore repeated follow-up logs at first and identify the first line that names the failure.

範例

TypeError: Cannot read properties of undefined

請求範例

Find the first real error line in this log.

訊息結構

Error name

Error name

SyntaxError, TypeError, ReferenceError

意思

The error name tells you the broad class of problem.

閱讀方式

Use it to separate syntax, runtime, type, network, and environment problems.

範例

SyntaxError, TypeError, ReferenceError

請求範例

Classify this error by error name before suggesting a fix.

訊息結構

Error message

Error message

Module not found: Can't resolve '@/lib/error-message-guide'

意思

The message explains what the tool could not do.

閱讀方式

Read the verb and object: could not resolve a module, could not read a property, or could not bind a port.

範例

Module not found: Can't resolve '@/lib/error-message-guide'

請求範例

Rewrite this error message in plain Korean and point to the likely cause.

訊息結構

Stack trace

Stack trace

at SiteHeader (src/components/SiteHeader.tsx:42:15)

意思

A list of function calls that led to the error.

閱讀方式

Find the first line that points to your project file, then inspect that area.

注意

The top stack line is not always your code. Some lines are framework internals.

範例

at SiteHeader (src/components/SiteHeader.tsx:42:15)

請求範例

In this stack trace, identify the first line from my project.

位置線索

File path

File path

src/components/LanguageSwitcher.tsx

意思

The path tells you which file the tool thinks is involved.

閱讀方式

Prefer paths under src, app, components, or lib before inspecting dependency folders.

範例

src/components/LanguageSwitcher.tsx

請求範例

List the project files mentioned by this error.

位置線索

Line and column

Line and column

src/app/page.tsx:27:12

意思

Line and column narrow the location to a specific character area.

閱讀方式

Inspect the named line plus a few lines above it, because the real cause can start earlier.

範例

src/app/page.tsx:27:12

請求範例

Open the file around the reported line and explain what looks wrong.

位置線索

Project file line

Project file line

src/lib/git-github.ts:143:7

意思

A stack or build line that points to your source code instead of a dependency.

閱讀方式

This is usually the line to inspect before reading long framework traces.

範例

src/lib/git-github.ts:143:7

請求範例

Separate my project file lines from framework lines.

位置線索

node_modules line

node_modules line

node_modules/next/dist/server/app-render.js

意思

A line inside an installed dependency or framework package.

閱讀方式

Treat it as context unless the log also points to a package version or configuration problem.

注意

Do not edit node_modules as a normal fix.

範例

node_modules/next/dist/server/app-render.js

請求範例

Tell me whether this node_modules line is the cause or just context.

JavaScript 執行錯誤

SyntaxError

SyntaxError

SyntaxError: Unexpected token '}'

意思

JavaScript or TypeScript could not parse the code.

閱讀方式

Check brackets, quotes, commas, JSX tags, and incomplete expressions near the reported line.

範例

SyntaxError: Unexpected token '}'

請求範例

Find the syntax problem around this line.

JavaScript 執行錯誤

TypeError

TypeError

TypeError: Cannot read properties of undefined

意思

A value did not have the shape or behavior the code expected at runtime.

閱讀方式

Check whether the value can be undefined, null, a string instead of an object, or a missing function.

範例

TypeError: Cannot read properties of undefined

請求範例

Trace where this undefined value comes from.

JavaScript 執行錯誤

ReferenceError

ReferenceError

ReferenceError: copy is not defined

意思

The code tried to use a variable or function name that is not available in that scope.

閱讀方式

Check imports, spelling, scope, and whether the variable is declared before use.

範例

ReferenceError: copy is not defined

請求範例

Find why this name is not defined.

JavaScript 執行錯誤

Cannot read properties of undefined

Cannot read properties of undefined

Cannot read properties of undefined (reading 'navLabel')

意思

The code tried to access a property on a value that is undefined.

閱讀方式

Check the object before the dot, such as copy, locale, params, or a map lookup result.

範例

Cannot read properties of undefined (reading 'navLabel')

請求範例

Identify which value is undefined in this error.

JavaScript 執行錯誤

is not a function

is not a function

setOpenMenu is not a function

意思

The code tried to call something with parentheses, but the value is not a function.

閱讀方式

Check whether a prop, import, hook result, or object method has the expected name.

範例

setOpenMenu is not a function

請求範例

Find why this value is being called as a function.

Next.js 與 Web

Module not found

Module not found

Module not found: Can't resolve '@/lib/error-message-guide'

意思

The bundler could not find the file or package named in an import.

閱讀方式

Check the file exists, the path spelling is exact, and the alias points to the expected folder.

範例

Module not found: Can't resolve '@/lib/error-message-guide'

請求範例

Check the import path and the actual file path.

Next.js 與 Web

Export not found

Export not found

Export errorMessageGuideCopy doesn't exist in target module

意思

The import name does not match any export from the target file.

閱讀方式

Compare the imported name with the exact exported const, function, or type name.

範例

Export errorMessageGuideCopy doesn't exist in target module

請求範例

Find the mismatched import or export name.

Next.js 與 Web

Hydration failed

Hydration failed

Hydration failed because the server rendered HTML didn't match the client

意思

The HTML generated on the server did not match what React rendered in the browser.

閱讀方式

Check browser-only values, dates, random values, localStorage, and theme state used during initial render.

範例

Hydration failed because the server rendered HTML didn't match the client

請求範例

Find the likely server and client render mismatch.

Next.js 與 Web

404 Not Found

404 Not Found

GET /ko/reference/error-message-guide 404

意思

The requested route or file could not be found.

閱讀方式

Check the route folder, generateStaticParams, link href, and exported static output path.

範例

GET /ko/reference/error-message-guide 404

請求範例

Check why this route returns 404.

Next.js 與 Web

500 Internal Server Error

500 Internal Server Error

GET /ko 500

意思

The server received the request but failed while processing it.

閱讀方式

Look at the terminal log from the same request, not only the browser status code.

範例

GET /ko 500

請求範例

Match this browser 500 with the terminal error that caused it.

TypeScript 與 lint

Property does not exist on type

Property does not exist on type

Property 'navLabel' does not exist on type 'string'

意思

TypeScript says the value's declared type does not include that property.

閱讀方式

Check whether the value has the correct type, whether it was indexed correctly, and whether the data shape changed.

範例

Property 'navLabel' does not exist on type 'string'

請求範例

Explain why TypeScript thinks this property does not exist.

TypeScript 與 lint

Type is not assignable

Type is not assignable

Type 'string' is not assignable to type 'Locale'

意思

A value is being passed somewhere that expects a different type.

閱讀方式

Compare the actual value type with the expected type named after 'to type'.

範例

Type 'string' is not assignable to type 'Locale'

請求範例

Show the actual type and expected type in this error.

TypeScript 與 lint

ESLint error

ESLint error

React Hook useEffect has a missing dependency

意思

A static analysis rule found code that may be unsafe, inconsistent, or against project style.

閱讀方式

Read the rule name and the file line, then decide whether the code or dependency list should change.

範例

React Hook useEffect has a missing dependency

請求範例

Explain this lint error and fix it without changing behavior.

Next.js 與 Web

Build failed

Build failed

Failed to compile.

意思

The production build could not finish.

閱讀方式

Scroll above the summary and find the first compile, type, lint, or route error.

範例

Failed to compile.

請求範例

From this build log, identify the first blocking failure.

終端機與系統

EADDRINUSE

EADDRINUSE

Error: listen EADDRINUSE: address already in use :::3001

意思

The server tried to use a port that another process is already using.

閱讀方式

Stop the old server or run the new server on a different port.

範例

Error: listen EADDRINUSE: address already in use :::3001

請求範例

Find what is using this port and suggest the safest next step.

終端機與系統

ENOENT

ENOENT

ENOENT: no such file or directory, open 'next.config.js'

意思

The process tried to open a file or folder that does not exist at that path.

閱讀方式

Check the current working directory, filename spelling, extension, and generated files.

範例

ENOENT: no such file or directory, open 'next.config.js'

請求範例

Check whether this file is missing or the command is running from the wrong folder.

終端機與系統

Permission denied

Permission denied

Operation not permitted

意思

The process does not have permission to read, write, or execute the target.

閱讀方式

Check sandbox rules, file permissions, protected folders, and whether approval is needed.

注意

Do not fix permission errors by broadly changing permissions unless you understand the target.

範例

Operation not permitted

請求範例

Explain why this permission error happened and what approval is needed.

終端機與系統

Command not found

Command not found

zsh: command not found: next

意思

The shell cannot find an executable command with that name.

閱讀方式

Check whether dependencies are installed, whether npm scripts should be used, and whether PATH is set.

範例

zsh: command not found: next

請求範例

Tell me whether I should run an npm script instead of this command.

除錯順序

Warning

Warning

DeprecationWarning: module.register() is deprecated

意思

A warning says something may need attention, but it may not stop the current command.

閱讀方式

Check whether the command still completed successfully before treating the warning as a failure.

範例

DeprecationWarning: module.register() is deprecated

請求範例

Separate blocking errors from non-blocking warnings in this output.

除錯順序

DeprecationWarning

DeprecationWarning

DeprecationWarning: module.register() is deprecated

意思

A feature still works now but is planned to be replaced or removed later.

閱讀方式

If build passes, record it as a follow-up unless it points to your code or a required upgrade.

範例

DeprecationWarning: module.register() is deprecated

請求範例

Tell me whether this DeprecationWarning blocks deployment.

除錯順序

Recent change

Recent change

The error started after editing SiteHeader.tsx

意思

The most recent related edit is often the highest-value clue.

閱讀方式

Compare the error location with files modified in the current task.

範例

The error started after editing SiteHeader.tsx

請求範例

Compare this error with the files changed most recently.

除錯順序

Reproduce step

Reproduce step

Open /ko, click the language menu, then click the site menu

意思

The smallest action sequence that makes the error appear again.

閱讀方式

Clear reproduce steps make it possible to verify that the fix actually works.

範例

Open /ko, click the language menu, then click the site menu

請求範例

Turn this description into exact reproduce steps.

除錯順序

Minimal log

Minimal log

Error line + file path + stack line from src

意思

A short set of log lines that preserves the actual failure and location.

閱讀方式

Keep the first error, the project file path, the command, and the final success or failure summary.

範例

Error line + file path + stack line from src

請求範例

Compress this long log into the minimal lines needed for debugging.