vite build silently skips static export when invoked through npm's `.bin/vite` entry on Linux
Summary
With vinext 1.0.0 and output: "export", running vite build through an npm script on Linux can exit successfully without generating static HTML files.
The Vite bundles are generated, but vinext's prerendering phase is skipped. This caused a downstream build in our GitHub Actions workflow to fail because dist/client/index.html was missing.
Environment
- vinext: 1.0.0
- Vite: 8.2.0
- Node.js: 22.23.2
- npm: 10.9.8
- CI: GitHub Actions,
ubuntu-latest - Router: App Router
Configuration
// vite.config.ts
import vinext from "vinext";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [vinext()],
});// next.config.ts
export default {
output: "export",
trailingSlash: true,
};{
"scripts": {
"build": "vite build"
}
}Reproduction
- Configure an App Router application as above, with a statically renderable root page and root layout.
- Install dependencies with npm on Linux.
- Run
npm run build. - Check whether
dist/client/index.htmlexists.
Expected behavior
The build runs static export and generates the HTML and RSC files required to serve the application without a Node.js server.
Actual behavior
The build exits with code 0 and generates the JavaScript bundles, but dist/client/index.html is missing. The CI build log contains no prerendering phase.
The frontend artifact upload and download both succeed, so the missing HTML is only detected by a downstream consumer.
Possible root cause
In packages/vinext/src/utils/vite-cli-invocation.ts, commandArguments() recognizes Vite using these entry-path suffixes:
entry.endsWith("/vite/bin/vite.js") ||
entry.endsWith("/vite/node/cli.js") ||
entry.endsWith("/dist/vite/node/cli.js")An npm invocation on Linux can use an entry path such as:
/app/node_modules/.bin/viteThat path does not match the checks above. As a result, claimViteCliBuildInvocation() returns false, leaving vinext's build lifecycle disabled and skipping static export.
The detection difference can be reproduced directly against the installed package:
import { getViteCliInvocation } from "./node_modules/vinext/dist/utils/vite-cli-invocation.js";
console.log(
getViteCliInvocation([
"/usr/bin/node",
"/app/node_modules/.bin/vite",
"build",
]),
);
// undefined
console.log(
getViteCliInvocation([
"/usr/bin/node",
"/app/node_modules/vite/bin/vite.js",
"build",
]),
);
// An invocation with command: "build"I also tested a minimal App Router fixture locally on Windows while simulating the Linux npm entry in process.argv:
- The
.bin/viteentry reproduced a successful build with noindex.html. - Running through the
vinext buildproxy generated the root HTML, 404 page, and RSC payload.
The original missing-export failure was observed in the Ubuntu CI job; the minimal fixture verification used simulated Linux-style arguments.
Workaround
Using either of the following avoids the entry-path mismatch:
{
"scripts": {
"build": "vinext build"
}
}Or:
{
"scripts": {
"build": "node node_modules/vite/bin/vite.js build"
}
}The vinext build proxy resolves the project-local Vite CLI and updates process.argv before invoking it.
Possible fix
Resolve the CLI entry's symlink before classifying the invocation, and add regression coverage that launches vite build through a real npm script on Linux.
Related PRs: #3377, #3497, #3381.
Source: cloudflare/vinext