vite: Fails to load config with `Excepted identifier but found "import"` error
Note: vite@6.0.5 is out pinning to esbuild 0.24.0 until @sapphi-red’s PR to esbuild is merged and released, you can update to latest vite to fix this issue. Leaving this issue open as we’ll revert the temporary fix soon.
Workaround and the cause
It seems a change in esbuild 0.24.1 is affecting Vite’s config loader: https://github.com/evanw/esbuild/issues/4010
The current workaround is to set overrides in package managers:
- pnpm overrides
"pnpm": { "overrides": { "esbuild": "0.24.0" } } - npm overrides
{ "overrides": { "esbuild": "0.24.0" } } - yarn resolutions
{ "resolutions": { "esbuild": "0.24.0" } }
Edited by @sapphi-red
Describe the bug
Reproduction
pnpm create vite@latest; babel-react
Steps to reproduce
No response
System Info
System:
OS: macOS 15.0
CPU: (8) arm64 Apple M1 Pro
Memory: 144.56 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.3.0 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.9.0 - /usr/local/bin/npm
pnpm: 9.15.0 - /usr/local/bin/pnpm
bun: 1.1.28 - ~/.bun/bin/bun
Browsers:
Chrome: 131.0.6778.205
Safari: 18.0
npmPackages:
@vitejs/plugin-react: ^4.3.4 => 4.3.4
vite: ^6.0.3 => 6.0.4
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 67
- Comments: 48 (3 by maintainers)
I found the same problem in my environment, but the following command temporarily solved it. I hope it works in your environment as well.
npm i -D esbuild@0.24.0
It seems a change in esbuild 0.24.1 is affecting Vite’s config loader: https://github.com/evanw/esbuild/issues/4010
The current workaround is to set overrides in package managers:
vite@6.0.5 is out pinning to esbuild 0.24.0 until @sapphi-red’s PR to esbuild is merged and released, you can update to latest vite to fix this issue
Looks like fix on the way: https://github.com/evanw/esbuild/pull/4013
Now that esbuild has released v0.24.2, is it possible to undo #19027?
On my project this override worked
Then delete the
node_modulesfolder and runnpm install俺也一样
#19043 has upgraded esbuid version to
^0.24.2, and vite 6.0.6 has been released.The override does not work in a mono repo
it because of es build run “npm install -D vite@^5” on your project root, this version have stable esbuild
“vite”: “^6.0.4” is causing the issue. Downgrading works at this moment. You can downgrade:
Wasted so much time on this. I’m using vite@5.5.5 now
downgrade vite version working for now. run this in your project directory
npm uninstall vitenpm i -D vite@5or simplynpm i -D vite@5