# Next Build Node Runtime

> Use when Cook Web npm run build fails with SyntaxError Unexpected token '?' or next/dist/compiled errors. Check for mismatched Node runtime versions first.

- Skill: `ai-shifu/next-build-node-runtime` (Agent Skill)
- Install (CLI): `npx get-skill add ai-shifu/next-build-node-runtime`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ai-shifu/next-build-node-runtime/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ai-shifu (https://skillmd.com/u/ai-shifu)
- Updated: 2026-11-16
- Page: https://skillmd.com/skills/ai-shifu/next-build-node-runtime

---


# Next Build Node 运行时排障

## 触发条件

- `npm run build` 在 `next/dist/compiled` 内部文件报语法错误。
- 报错包含 `SyntaxError: Unexpected token '?'`、`Unexpected token '.'` 等现代语法不兼容信息。
- 构建日志中 Warning 很多，但实际中断点不明确。

## 工作流

1. 在当前目录分别检查运行时版本与路径：`node -v`、`npm -v`、`which node`、`which npm`。
2. 对照 `package.json` 的 `engines.node`，确认是否匹配。
3. 如果 shell 初始化脚本切到了旧 Node，先切到项目要求版本再重新执行 `npm run build`。
4. 构建失败时只抓第一个 `Error` 作为阻断点，不把 `Warning` 当作失败原因。
5. 若阻断点是 ESLint `Error`，做最小改动修复；保留调试日志，不删除 `console.log`。

