fix(ci): Frontend Lint使用本地二进制替代npx,避免自动下载不兼容版本 #346

Closed
xiaoxia wants to merge 1 commits from fix/frontend-lint-npx-local into develop
Owner

问题

多个PR的Frontend Lint失败,根因是 npx eslint 自动下载了 eslint@10.7.0(最新版),而项目锁定的是 eslint@^8.57.0

失败链路:

  1. npm缓存脏数据 → 缓存命中但node_modules里没有eslint
  2. npx eslint 找不到本地版本 → 自动下载npm上的最新版
  3. eslint@10 只支持 flat config(eslint.config.js),不认项目的 .eslintrc.* → 直接报错

修复

将Frontend Lint中的三个npx调用全部改为本地二进制路径:

  • npx eslintnode_modules/.bin/eslint
  • npx tscnode_modules/.bin/tsc
  • npx prettiernode_modules/.bin/prettier

效果:本地没有对应二进制时直接失败(command not found),不会偷偷下载最新不兼容版本,问题暴露更直接。

配合PR #345的缓存完整性校验,形成双重保障:

  1. 缓存校验不通过 → 自动重装依赖
  2. 即使校验漏网 → 本地命令不存在直接报错,不会拉下大版本搞破坏

相关PR

  • #341: 引入npm缓存机制(源头)
  • #345: 增加缓存完整性校验 + 失败重试(第一层防护)
  • #346: 本PR - 使用本地二进制替代npx(第二层防护)
## 问题 多个PR的Frontend Lint失败,根因是 `npx eslint` 自动下载了 `eslint@10.7.0`(最新版),而项目锁定的是 `eslint@^8.57.0`。 失败链路: 1. npm缓存脏数据 → 缓存命中但node_modules里没有eslint 2. `npx eslint` 找不到本地版本 → 自动下载npm上的最新版 3. eslint@10 只支持 flat config(`eslint.config.js`),不认项目的 `.eslintrc.*` → 直接报错 ## 修复 将Frontend Lint中的三个npx调用全部改为本地二进制路径: - `npx eslint` → `node_modules/.bin/eslint` - `npx tsc` → `node_modules/.bin/tsc` - `npx prettier` → `node_modules/.bin/prettier` **效果**:本地没有对应二进制时直接失败(command not found),不会偷偷下载最新不兼容版本,问题暴露更直接。 配合PR #345的缓存完整性校验,形成双重保障: 1. 缓存校验不通过 → 自动重装依赖 2. 即使校验漏网 → 本地命令不存在直接报错,不会拉下大版本搞破坏 ## 相关PR - #341: 引入npm缓存机制(源头) - #345: 增加缓存完整性校验 + 失败重试(第一层防护) - #346: 本PR - 使用本地二进制替代npx(第二层防护)
xiaoxia added 1 commit 2026-07-15 10:07:18 +08:00
fix(ci): Frontend Lint使用本地二进制替代npx,避免自动下载不兼容版本
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 53s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 2m43s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m52s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m12s
e295cf27c7
xiaoxia closed this pull request 2026-07-15 10:49:52 +08:00
Author
Owner

关闭,与 PR #347 功能重复。

#347 方案更完整:不仅用 npx --no-install 防止下载错误版本,还补上了 prettier 到 devDependencies(之前 prettier 不在依赖里,全靠 npx 现场下载)。

#346 的直接路径方案 node_modules/.bin/xxx 因 prettier 缺失同样会失败。

关闭,与 PR #347 功能重复。 #347 方案更完整:不仅用 `npx --no-install` 防止下载错误版本,还补上了 `prettier` 到 devDependencies(之前 prettier 不在依赖里,全靠 npx 现场下载)。 #346 的直接路径方案 `node_modules/.bin/xxx` 因 prettier 缺失同样会失败。
Some checks are pending
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 53s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 2m43s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m52s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m12s

Pull request closed

Sign in to join this conversation.