Skip to content

fix(#219): replace __dirname with ESM-compatible alternative - #228

Open
Siddh2024 wants to merge 1 commit into
arzoo0511:mainfrom
Siddh2024:fix/219-esm-dirname
Open

fix(#219): replace __dirname with ESM-compatible alternative#228
Siddh2024 wants to merge 1 commit into
arzoo0511:mainfrom
Siddh2024:fix/219-esm-dirname

Conversation

@Siddh2024

Copy link
Copy Markdown

Fixes #219

Changes

  • Added import { fileURLToPath } from node:url import
  • Added __filename and __dirname definitions using import.meta.url
  • Existing path.resolve(__dirname, ...) calls now work in ESM context

Impact

  • Vite dev server no longer crashes on startup with ReferenceError: __dirname is not defined
  • Production builds succeed
  • Service worker compilation restored

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

@Siddh2024 is attempting to deploy a commit to the arzoorai0207-5745's projects Team on Vercel.

A member of the Team first needs to authorize it.

Since package.json has type: module, __dirname is undefined in ESM. Replaced with fileURLToPath(import.meta.url) to fix dev server crash and production build failure.
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ecoplay Error Error Jul 18, 2026 6:38am

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.

BUG: __dirname used in ESM context crashes Vite plugin at startup

1 participant