Skip to content

fix(website): make the dev clean step work on Windows - #332

Merged
yiliang114 merged 1 commit into
mainfrom
fix/website-windows-clean
Oct 22, 2026
Merged

yiliang114 merged 1 commit into
mainfrom
fix/website-windows-clean

Conversation

@yiliang114

Copy link
Copy Markdown
Collaborator

npm run dev cannot start on Windows: clean shells out to rm -rf .next, and npm runs scripts through cmd.exe, where rm does not exist. PowerShell is not a workaround either — there rm aliases Remove-Item, and -rf is not a valid parameter. Tracked in #331.

Reproduced on Windows Server 2025 (10.0.26100, Node 22.23.1, npm 10.9.8) against this repository's website/package.json, before the change:

> website@1.0.0 clean
> rm -rf .next

'rm' is not recognized as an internal or external command,
operable program or batch file.
exit=1
next exists after=True

Changes

  • website/package.json — clean now removes .next through Node's fs.rmSync, the same Node fs API that build already relies on through scripts/clean-next.mjs. dev still runs generate → clean → next dev; no other script changes, no dependency or lockfile changes.

Verification

  • Windows, after the change: npm run clean exits 0 and removes a seeded .next.
  • macOS: npm run clean exits 0 and removes a seeded .next; the package file still parses as JSON.
  • CI and deploy are Linux-only and do not touch clean; build keeps its cache-preserving clean-next.mjs path.

Honest limit: I did not run the full npm run dev on Windows (it needs npm ci plus the dev server). The failing step was clean, and that is the only thing this changes.

中文说明

Windows 下 npm run dev 起不来:clean 调 rm -rf .next,而 npm 在 Windows 上通过 cmd.exe 跑脚本,没有 rm;PowerShell 里 rm 是 Remove-Item 的别名,-rf 也不是合法参数。本仓库的 build 已经走 scripts/clean-next.mjs,只有 dev 这条路还依赖 POSIX 命令;CI 和部署都在 Linux,所以只影响本地开发。

改动只有一行:clean 改用 Node 的 fs.rmSync。Windows Server 2025 上修改后 npm run clean 退出 0 且 .next 被删除,macOS 同样通过,build 的缓存保留逻辑不动。

Fixes #331

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patrol-Run: qwen-docs-pr-review

Posting as COMMENT rather than APPROVE: gh is authenticated as the PR author here, and GitHub rejects self-approval with Can not approve your own pull request (HTTP 422). The review content is unchanged.

Approving. One-line change, and it does what the description says.

What I checked:

  • website/package.json has no type field, so node -e runs as CommonJS and require resolves. I ran the exact command locally in both a CommonJS and a "type": "module" package: exit 0 with a seeded .next removed, and exit 0 again with .next already absent. force: true keeps it idempotent, matching rm -rf.
  • dev is untouched (generate → clean → next dev), and build still goes through scripts/clean-next.mjs (present, 1039 bytes), so the cache-preserving path is unchanged.
  • No workflow calls npm run clean: the only references in the repo are the dev script itself and prose in */developers/contributing.md. Every runner is ubuntu-latest, and on Linux rmSync('.next', {recursive: true, force: true}) is behaviourally equivalent to rm -rf .next regardless.
  • fs.rmSync needs Node >= 14.14; the repo requires >= 22.
  • No dependency, lockfile, or unrelated change in the diff.
  • Both checks on this head are green (Website unit tests, Translator unit tests).

Not checked: I did not run this on Windows myself — the Windows Server 2025 evidence is yours, not mine. I also did not run the full npm run dev, which you already flagged.

@yiliang114
yiliang114 merged commit 1df519e into main Oct 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

website: local dev fails on Windows because clean runs rm -rf

1 participant