知其然,知其所以然
常见报错实测 2026-10-29

Git Unable to create '.git/index.lock': File exists:14 个命令只有 5 个被挡,commit -a 的钩子期间握着锁,手工删锁会让 commit 报错

实测 Git fatal: Unable to create .git/index.lock: File exists:14 个命令里只有写暂存区的 5 个被挡;git commit -a 在 pre-commit 钩子期间握着锁而普通 commit 不握;钩子运行时手工删锁会让 commit 报 repository has been updated, but unable to write new index file;HEAD.lock 与 config.lock 的报错不同;两个进程各 add 100 个文件有 80 次撞锁。

Git index.lock Unable to create index.lock File exists git add pre-commit 报错 真实验证 动画演示
常见报错实测 2026-10-29

Git Author identity unknown / Please tell me who you are:这台 macOS 默认自动拼身份也能提交,要 useConfigOnly 才报错,优先级实测

实测 Git *** Please tell me who you are / Author identity unknown:这台 macOS 默认会自动拼登录名@主机名并成功提交,要设 user.useConfigOnly 才报错;哪些命令需要身份(commit、revert、tag -a)哪些不要(add、stash);全局、仓库、-c、环境变量的优先级;includeIf 按目录换邮箱;配错身份后 amend 与 rebase 的修法。

Git Author identity unknown Please tell me who you are user.name user.email includeIf 报错 真实验证 动画演示
常见报错实测 2026-10-29

Git push 大文件被拒:再提交一次删除没用,gc 后 .git 从 12432 KB 降到 120 KB,已推送的要重写历史

实测 Git push 大文件被拒:服务端上限 5 MiB、本地 12 MiB 文件得到 remote rejected (unpacker error);再提交一次删除没用;没推送过就 reset --soft 重提,gc 后 .git 12432 KB 降到 120 KB;已推送要 filter-branch 重写并强制推送,服务端旧对象需要它自己 gc;Git LFS 指针只有 133 字节。

Git git push 大文件 pack exceeds maximum allowed size filter-branch Git LFS 报错 真实验证 动画演示
常见报错实测 2026-10-29

npm ERESOLVE unable to resolve dependency tree:--legacy-peer-deps 和 --force 装出的结果与锁文件完全相同,只差一个警告

实测 npm ERESOLVE unable to resolve dependency tree:Found / Could not resolve dependency 两块怎么读;--legacy-peer-deps 与 --force 装出的结果和锁文件完全相同,只是后者打印警告;换兼容版本、overrides 的效果;npm 7 以后自动安装 peer 依赖,.npmrc 里设置 legacy-peer-deps 的含义。

npm ERESOLVE unable to resolve dependency tree peer dependency legacy-peer-deps force overrides 报错 真实验证 动画演示
常见报错实测 2026-10-29

Node.js Error: listen EADDRINUSE:不同监听地址互相冲突的完整矩阵,127.0.0.1 与 :: 同端口时请求归谁,reusePort 在 macOS 上 ENOTSUP

实测 Node.js Error: listen EADDRINUSE: address already in use :::端口:err.code、errno -48 和 :::9701 怎么读,lsof 找占用进程;不同 host(::、0.0.0.0、127.0.0.1、::1、localhost)互相是否冲突的完整矩阵,以及 127.0.0.1 与 :: 同端口时请求被谁处理;reusePort 在 macOS 上是 ENOTSUP;父进程被杀后子进程仍占端口。

Node.js EADDRINUSE address already in use listen lsof 端口占用 报错 真实验证 动画演示
常见报错实测 2026-10-29

Node.js EMFILE: too many open files:ulimit -n 256 只能打开 245 个,console.log 自己也会崩,createReadStream 与 fs.watch 才会触发

实测 Node.js EMFILE: too many open files:ulimit -n 256 时只能打开 245 个(node 自己占 11 个),描述符用尽时 console.log 本身会崩溃;套接字同样占描述符;fs.promises.readFile 和 readFile 回调一次读 3000 个文件没有失败而 createReadStream 失败,限制并发 64 后全部成功;fs.watch 每个文件一个描述符。

Node.js EMFILE too many open files ulimit fs.watch createReadStream 报错 真实验证 动画演示
常见报错实测 2026-10-29

Node.js ERR_REQUIRE_ESM、Cannot use import statement outside a module:Node 26 上默认已不再报,什么情况下还会报

实测 Node 26 上 ERR_REQUIRE_ESM、Cannot use import statement outside a module 还剩什么:没有 package.json 时 import 直接能跑,type 没写时只有性能警告,type: commonjs 才报老错误;require(esm) 默认可用,含顶层 await 才报 ERR_REQUIRE_ASYNC_MODULE;具名导入 CJS、省略扩展名、目录 import、__dirname 等 ESM 报错的实际文字与修法。

Node.js ERR_REQUIRE_ESM Cannot use import statement outside a module require(esm) ERR_MODULE_NOT_FOUND ESM CommonJS 报错 真实验证 动画演示
常见报错实测 2026-10-29

Node.js FATAL ERROR: JavaScript heap out of memory:默认上限 4192 MB 怎么来,Buffer 为什么不触发,44 MB 的 JSON.parse 要占 92 MB

实测 Node.js FATAL ERROR: JavaScript heap out of memory:这台 16 GiB 的机器默认上限 4192 MB,--max-old-space-size 的报告值 = 设置值 + 96 MB;Node 26 的文字是 Ineffective mark-compacts near heap limit;上限翻倍能放的对象约翻倍;Buffer 300 MB 不触发而普通数组触发;44 MB 的 JSON.parse 后堆里 92 MB。

Node.js JavaScript heap out of memory max-old-space-size Ineffective mark-compacts JSON.parse Buffer 报错 真实验证 动画演示
常见报错实测 2026-10-29

Node.js TypeError: fetch failed:原因都在 e.cause 里,localhost 是 AggregateError,AbortSignal.timeout 是 TimeoutError

实测 Node.js TypeError: fetch failed:message 永远只有 fetch failed,真正的原因在 e.cause;localhost 的 cause 是 AggregateError,要读 .errors;ECONNRESET、UND_ERR_SOCKET、HTTPParserError、DEPTH_ZERO_SELF_SIGNED_CERT、ENOTFOUND、unknown scheme 各自的样子;AbortSignal.timeout 得到的是 TimeoutError;按 cause.code 决定是否重试。

Node.js TypeError: fetch failed ECONNREFUSED AggregateError AbortSignal.timeout cause UND_ERR_SOCKET 报错 真实验证 动画演示
常见报错实测 2026-10-29

Nginx 502 Bad Gateway:error.log 里 connect() failed、prematurely closed、sent too big header 各是什么故障,上游全挂后恢复要等 fail_timeout

实测 Nginx 502 Bad Gateway:error.log 里 connect() failed (61: Connection refused)、upstream prematurely closed connection、Connection reset by peer、upstream sent too big header 各对应什么上游故障;上游自己返回的 502 与 nginx 生成的 502 怎么区分;proxy_buffer_size 与 error_page 的效果;两台上游都挂后,恢复也要等 fail_timeout(2.5 s 才首次成功)。

Nginx 502 Bad Gateway connect() failed upstream prematurely closed connection no live upstreams proxy_pass 报错 真实验证 动画演示
常见报错实测 2026-10-29

Nginx 504 Gateway Time-out:proxy_read_timeout 是读间隔不是总时长,GET 超时会换上游重试而 POST 不会,默认 60 s 实测

实测 Nginx 504 Gateway Time-out:error.log 的 upstream timed out (60: Operation timed out) while reading response header from upstream;proxy_read_timeout 是两次读之间的间隔不是总时长(4 s 的涓流响应 1 s 超时也完整返回);响应体中途停住时客户端看到的不是 504;GET 超时会被换到下一台上游重试而 POST 不会;默认值实测 60.0 s。

Nginx 504 Gateway Time-out upstream timed out proxy_read_timeout proxy_next_upstream 报错 真实验证 动画演示
常见报错实测 2026-10-29

Nginx 413 Request Entity Too Large:默认 1 MiB 的边界精确到 1 字节,client_max_body_size 写在哪个 location 才生效

实测 Nginx 413 Request Entity Too Large:默认限制 1 MiB,1048576 字节通过、1048577 字节 413;client_max_body_size 放在哪个 location 才生效;0 表示不检查;有 Content-Length 时读完请求头就拒绝、分块传输要读到超过才拒绝;error_page 把 413 换成 JSON;上游自己返回的 413 怎么分辨。

Nginx 413 Request Entity Too Large client_max_body_size client intended to send too large body error_page 报错 真实验证 动画演示
京ICP备2026067502号-1京公网安备11010502063487号