Skip to content

Vite module resolution forced to be node. Breaks workers environments #14730

@chrisvltn

Description

@chrisvltn

Reproduction

  1. Clone the repository https://github.com/chrisvltn/react-router-issue-reproduction
git clone https://github.com/chrisvltn/react-router-issue-reproduction.git
  1. Run pnpm install
  2. Run pnpm dev
  3. Open the dev environment in the browser

You'll see errors when importing node-specific libraries (http, https, etc.).

This reproduction environment uses the Cloudflare official template as base.

The fix branch shows a workaround fix - to add a custom Vite plugin that removes the node conditions in vite.config.ts.

System Info

System:
    OS: macOS 15.7.2
    CPU: (10) arm64 Apple M1 Max
    Memory: 2.11 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.3.0
    npm: 11.7.0
    pnpm: 10.26.0
  Browsers:
    Chrome: 143.0.7499.193
    Edge: 143.0.3650.139
    Firefox: 139.0.4
    Firefox Nightly: 131.0a1
    Safari: 18.6
    Safari Technology Preview: 26.0
  npmPackages:
    @react-router/dev: ^7.10.0 => 7.12.0 
    react-router: ^7.10.0 => 7.12.0 
    vite: ^7.1.7 => 7.3.1

Used Package Manager

pnpm

Expected Behavior

Page to load normally

Actual Behavior

Build breaks, as node versions of the dependency is used, which are incompatible with workers environment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions