Skip to content

@axiomhq/react does not work with vite getting Uncaught ReferenceError: process is not defined #302

@Supcar27

Description

@Supcar27

I'm experiencing an issue with logging in my React client-side rendered app that uses Vite. The application fails to load and throws the following error:

Uncaught ReferenceError: process is not defined

This error occurs in the platform.ts file where Axiom is checking an environment variable using process.env.

Packages I'm using:

  • "@axiomhq/js": "^1.3.1"
  • "@axiomhq/logging": "^0.1.4"
  • "@axiomhq/react": "^0.1.4"

Context

There is an open issue with Vite related to this problem here.

Temporary Solution

The only workaround that currently works in development is to add the following to the Vite configuration:

  define: {
    "process.env": process.env,
  },

While this solution is functional in development, it does not address the underlying problem.

Steps to Reproduce

  1. Set up a React app using Vite.
  2. Attempt to utilize Axiom for logging.
  3. Observe the error when loading the application.

Expected Behavior

The app should load without errors related to process.env.

Any insights or fixes would be greatly appreciated!

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions