## [ERR-20260418-001] `npx ts-node` 会拉全局最新版导致 TS5107 弃用错误

**日期**: 2026-04-18
**类别**: 脚本执行环境
**严重度**: 低（有明确绕行）

### 问题描述

跑 `npx ts-node --transpile-only testing/scripts/xxx.ts` 时报错：

```
TSError: Unable to compile TypeScript:
error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0
```

### 根本原因

`npx ts-node` 如果 npx 缓存里没装过，会**从 npm 拉最新版 ts-node**（以及它依赖的最新 TypeScript）。最新 TypeScript 对 `moduleResolution=node10` 给了弃用错误；即使 tsconfig 里写的是 `"moduleResolution": "node"`，新版 TS 会把 `node` 解析为 `node10` 并触发该错误。

项目的 `backend/node_modules/typescript` 是固定版本（5.7.3），不会触发这个问题。

### 绕行方案

**直接调用项目内的 ts-node**：

```bash
backend/node_modules/.bin/ts-node --project testing/scripts/tsconfig.json --transpile-only testing/scripts/xxx.ts
```

或者把常用脚本的调用写到 backend/package.json 的 scripts 里，让 npm run 自动用 node_modules 里的版本。

### 预防措施

- `testing/scripts/*.ts` 的文档和 README 不要写 `npx ts-node`，改写 `backend/node_modules/.bin/ts-node`
- CI 脚本使用绝对路径或 `npm exec`

### Metadata
- Reproducible: yes（任何机器上 npx 缓存为空时）
- Related Files: testing/scripts/*.ts
