Skip to content

Can't use in front end #21

@coltenkrauter

Description

@coltenkrauter

@krauters/logger relies on winston, which depends on Node.js modules like fs. This causes frontend builds (e.g., React, Next.js) to fail since fs is unavailable in the browser.

Steps to Reproduce

  1. Install @krauters/logger in a Next.js or React project.
  2. Import it in a client component or shared module.
  3. Run the app and observe the build error:
Module not found: Can't resolve 'fs'

Expected Behavior

The logger should work on the backend while gracefully handling frontend usage without breaking.

Potential Fixes

  • Ensure winston is only used in backend contexts.
  • Use a conditional import (typeof window === 'undefined').
  • Provide a fallback logger for frontend.
  • Update next.config.js to exclude fs from client builds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions