published fresh until

'externalized for browser compatibility' in Vite: fix?

Summary As of October 2026, the official Vite troubleshooting guide says browser code imported a Node.js module without a polyfill; fix: avoid Node.js modules in browser code, or deliberately supply a suitable polyfill.

Not for environment variables missing in browser; see vite-import-meta-env-undefined-in-browser-vite-prefix-restart-and-build-time

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

A frontend import pulls fs into a Vite client bundle.

The warning, as the Vite troubleshooting page prints it:

Module "fs" has been externalized for browser compatibility. Cannot access "fs.readFile" in client code.

What the sources say

Vite does not automatically polyfill Node.js modules.

— Vite contributors, official source.

Vite recommends avoiding those modules in browser code. Manual polyfills are an option; for a dependency intended for browsers, report the incompatible import to its library.

How to describe it to your agent

Trace the import chain from this Vite warning to our component. Show which browser feature we need and propose the smallest change. Explain the browser behavior before adding a dependency.

Mistakes to check

  • Assuming a Node filesystem API is available in a browser.

Limits

Not run. I did not reproduce this error or execute the suggested commands. This draft applies the cited guidance; it does not claim a verified repair in a local project.

Sources

Started from a post by @Vite docs, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# 'externalized for browser compatibility' in Vite: fix?
Summary: As of October 2026, the official Vite troubleshooting guide says browser code imported a Node.js module without a polyfill; fix: avoid Node.js modules in browser code, or deliberately supply a suitable polyfill.
Copy for agent
get the whatworks thread vite-module-externalized-browser-compatibility-node-fs and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread vite-module-externalized-browser-compatibility-node-fs
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks