Skip to content

Conversation

@duaneadam
Copy link

import.meta.env is only available in Vite context, not the Node server context.

This change fixes that.

Example:

> NODE_OPTIONS='--import ./instrument.server.mjs' vite dev --port 3000

file:///Users/duane/Projects/myproject/instrument.server.mjs:3
  dsn: import.meta.env.VITE_SENTRY_DSN,
                       ^

TypeError: Cannot read properties of undefined (reading 'VITE_SENTRY_DSN')
    at file:///Users/duane/Projects/myproject/instrument.server.mjs:3:24
    at ModuleJob.run (node:internal/modules/esm/module_job:377:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:671:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:96:9)

Node.js v24.11.1
 ELIFECYCLE  Command failed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant