I’m working on a React and TypeScript project using Vite for bundling. The issue arises during the build process. I’ve installed all dependencies correctly, and the dev server runs fine, but the build fails with errors related to import.meta.
Error:
Here’s the error message I’m getting:
X [ERROR] Expected identifier but found "import"
(define name):1:0:
1 │ import.meta.dirname
╵ ~~~~~~
X [ERROR] Expected identifier but found "import"
(define name):1:0:
1 │ import.meta.filename
╵ ~~~~~~
failed to load config from path/to/vite.config.ts
error during build:
Error: Build failed with 3 errors:
...
2
Answers
To resolve this issue, try downgrading
esbuild
to version0.24.0
by running the following command:This should fix the build errors related to
import.meta
.Thanks Kshtiz Ji for the answer and Arun for the Question. You saved my whole week. I have been trying this to fix.