Error codesBuild

Node-only code reaches the browser

MARKLESS_NODE_IN_BROWSERerrorMarkless raises it while Vite builds or serves your app.

The message

MARKLESS_NODE_IN_BROWSER: Node-only code is reachable from the browser build ("<environment>").

Words in angle brackets change from case to case.

Why

A module the browser loads imports a Node built-in like node:fs or os, directly or through other modules, or uses a global only Node has, like __dirname or Buffer. A browser has none of these. The build stops and lists every module from the page to the Node import.

Fix

Follow the list to the module your page actually needs. Move what it needs, often one constant or type, into its own file that imports nothing from Node, and import that file instead. Keep the Node work in server-only files.

// starter-ports.ts imports nothing from Nodeexport const STARTER_DEV_PORTS = { minimal: 5173 } as const;import { STARTER_DEV_PORTS } from './starter-ports.ts';
Where Markless raises it

All error codes