Windows: emptyDir EPERM fallback calls fs.rmdirSync with recursive, which Node.js 26 rejects
Astro Info
Astro v7.3.5
Vite v8.3.0
Node v26.8.2
System Windows (x64)
Package Manager npm
Output static
Adapter @astrojs/cloudflare (v14.3.3)
Integrations @astrojs/sitemap (v3.7.4)
static-security-headersIf this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
On Windows, when emptyDir (packages/astro/src/core/fs/index.ts) removes a path with fs.rmSync and gets EPERM, it calls fixWinEPERMSync. For a directory, that fallback calls fs.rmdirSync(p, options) with the same options, including recursive: true.
Node.js 26 no longer accepts recursive for rmdirSync, so the fallback throws instead of recovering:
TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.recursive' is no longer supported. Received true
The EPERM itself is intermittent on Windows (another process briefly holding a file in dist/), so the linked reproduction targets the failing call directly. We hit it during astro build with Astro 7.3.5 on Windows 11 and Node.js 26.8.2. This looks like the root cause of #14949, which was closed without a reproduction.
Suggested fix: in fixWinEPERMSync, call fs.rmSync(p, options) instead of fs.rmdirSync(p, options); rmSync accepts the same options. We apply exactly this one-line change as a local postinstall patch, and Windows builds succeed.
What's the expected result?
The fallback removes the directory recursively and the command continues, as it does on earlier Node.js versions.
Link to Minimal Reproducible Example
https://gist.github.com/hpagoda/d9c594183b7763b75b2341ca8a2d7005
Participation
- I am willing to submit a pull request for this issue.
Source: withastro/astro