Skip to content

node:util.styleText breaks browser compatibility #289

@yamcodes

Description

@yamcodes

When importing arkenv in browser environments (Vite, Bun frontend), the library fails with a module externalization error:

Error: Module "node:util" has been externalized for browser compatibility. 
Cannot access "node:util.styleText" in client code.

Reproduction:

  1. Import createEnv from arkenv in a Vite/Bun React component
  2. Run the dev server
  3. Error appears in browser console

Root Cause:

packages/arkenv/src/errors.ts imports styleText from node:util, which is Node-only.

Expected:

arkenv should work in both Node and browser environments without Node-specific dependencies.

Solution:

Replace node:util.styleText with a cross-platform alternative that works in browsers while maintaining zero dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arkenvChanges to the `arkenv` npm package.bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions