windmill-labs/windmill · warning

Bundle not found

Error message

Bundle not found

What it means

The local dev server started by `wmill app dev` (dev.ts) intercepts requests for `/dist/bundle.js` (or `/bundle.js`) and serves the file at `<cwd>/dist/bundle.js`. When that file does not exist on disk it responds with HTTP 404 and the body 'Bundle not found'. This is not a thrown exception but a 404 response the dev server generates, indicating the app bundle was never built or was built into a different directory.

Source

Thrown at cli/src/commands/app/dev.ts:923

      });
      res.write("data: connected\n\n");
      clients.push(res);

      req.on("close", () => {
        const index = clients.indexOf(res);
        if (index !== -1) clients.splice(index, 1);
      });
      return;
    }

    // Serve the bundled JS
    if (url === "/dist/bundle.js" || url === "/bundle.js") {
      const jsPath = path.join(process.cwd(), "dist/bundle.js");
      if (fs.existsSync(jsPath)) {
        res.writeHead(200, { "Content-Type": "application/javascript" });
        res.end(fs.readFileSync(jsPath));
      } else {
        res.writeHead(404);
        res.end("Bundle not found");
      }
      return;
    }

    // Serve the bundled CSS
    if (url === "/dist/bundle.css" || url === "/bundle.css") {
      const cssPath = path.join(process.cwd(), "dist/bundle.css");
      if (fs.existsSync(cssPath)) {
        res.writeHead(200, { "Content-Type": "text/css" });
        res.end(fs.readFileSync(cssPath));
      } else {
        res.writeHead(404);
        res.end("CSS not found");
      }
      return;
    }

View on GitHub (pinned to e474e8803c)

Solutions

  1. Build the app bundle first: from the app project root run the bundler (e.g. `wmill app bundle` or your npm build script) so `dist/bundle.js` exists.
  2. Verify you launched `wmill app dev` from the app root — the server resolves `path.join(process.cwd(), 'dist/bundle.js')` relative to the current working directory.
  3. Check the bundler terminal output for compile errors; a failed build leaves no bundle.js in dist/.
  4. Keep the bundler in watch mode so the bundle is regenerated after edits, then hard-reload the browser (cache-bust with Ctrl+Shift+R).
  5. If using a custom build script, confirm its outdir is `dist/` with entry `bundle.js` (or update the paths the dev server checks).

Example fix

// before: dev server started, bundle never built -> 404 'Bundle not found'
wmill app dev

// after: build (or watch) before/alongside dev
wmill app bundle --watch &
wmill app dev
Defensive patterns

Strategy: validation

Validate before calling

const jsPath = require('path').join(process.cwd(), 'dist/bundle.js');
if (!require('fs').existsSync(jsPath)) {
  throw new Error(`Missing ${jsPath} - run the bundler before 'wmill app dev'`);
}

Try / catch

try {
  const bundle = fs.readFileSync(path.join(process.cwd(), 'dist/bundle.js'));
  res.writeHead(200, { 'Content-Type': 'application/javascript' });
  res.end(bundle);
} catch (err) {
  if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
    res.writeHead(404);
    res.end('Bundle not found - run the bundler first');
  } else { throw err; }
}

Prevention

When it happens

Trigger: Browser (or the dev HTML shell) requests /dist/bundle.js while `wmill app dev` is running and `fs.existsSync(process.cwd() + '/dist/bundle.js')` is false — i.e. the JS bundle has not been produced by the bundler, or the CLI was launched from a directory whose dist/ folder lacks bundle.js.

Common situations: Starting `wmill app dev` before running the bundler/watcher that emits dist/bundle.js; bundler crashed or is still compiling on first load; running the CLI from the wrong working directory so it looks at a different dist/; cleaning dist/ while the dev server keeps serving; stale npm scripts that no longer emit to dist/.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/f0723d8e98759dbe. Report an issue: GitHub.