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:

Edited by @sapphi-red


Describe the bug

Screenshot 0006-12-20 at 14 20 15

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 67
  • Comments: 48 (3 by maintainers)

Most upvoted comments

I found the same problem in my environment, but the following command temporarily solved it. I hope it works in your environment as well.

pnpm add -D esbuild@=0.24.0
pnpm dedupe

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

Now that esbuild has released v0.24.2, is it possible to undo #19027?

On my project this override worked

{
  "name": "Your app",
  "devDependencies": {
    "vite": "^6.0.4",
  },
  "overrides": {
    "vite": {
      "esbuild": "0.24.0"
    }
  },
}

Then delete the node_modules folder and run npm install

俺也一样

image

Workaround and the cause

It seems a change in esbuild 0.24.1 is affecting Vite’s config loader: evanw/esbuild#4010

The current workaround is to set overrides in package managers:

Edited by @sapphi-red

Describe the bug

Screenshot 0006-12-20 at 14 20 15 ### 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

  "bun": {
      "overrides": {
        "esbuild": "0.24.0"
      }
    }

#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:

npm install vite@^5

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 vite npm i -D vite@5 or simply npm i -D vite@5