vite: Vite Version 6.0.4 is Not running in dev mode

Describe the bug

After installing new version of vite 6.0.4 vite is not working in dev mode but When i changed vite version to 5.0 its working.

Reproduction

npm create vite@latest

Steps to reproduce

npm run dev

System Info

node -v 18.20.5
npm 10.8.2
Ubuntu

Used Package Manager

npm

Logs

$ vite ✘ [ERROR] Expected identifier but found “import”

(define name):1:0:
  1 │ import.meta.dirname
    ╵ ~~~~~~

✘ [ERROR] Expected identifier but found “import”

(define name):1:0:
  1 │ import.meta.filename
    ╵ ~~~~~~

✘ [ERROR] Expected identifier but found “import”

(define name):1:0:
  1 │ import.meta.url
    ╵ ~~~~~~

failed to load config from /home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/vite.config.js error when starting dev server: Error: Build failed with 3 errors: (define name):1:0: ERROR: Expected identifier but found “import” (define name):1:0: ERROR: Expected identifier but found “import” (define name):1:0: ERROR: Expected identifier but found “import” at failureErrorWithLog (/home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/node_modules/esbuild/lib/main.js:1476:15) at /home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/node_modules/esbuild/lib/main.js:945:25 at runOnEndCallbacks (/home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/node_modules/esbuild/lib/main.js:1316:45) at buildResponseToResult (/home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/node_modules/esbuild/lib/main.js:943:7) at /home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/node_modules/esbuild/lib/main.js:970:16 at responseCallbacks.<computed> (/home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/node_modules/esbuild/lib/main.js:622:9) at handleIncomingPacket (/home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/node_modules/esbuild/lib/main.js:677:12) at Socket.readFromStdout (/home/abhishek/Workspace/Abhishek/DMS/dms-web-v2/node_modules/esbuild/lib/main.js:600:7) at Socket.emit (node:events:517:28) at addChunk (node:internal/streams/readable:368:12) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Validations

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 19
  • Comments: 21 (2 by maintainers)

Most upvoted comments

try pnpm add esbuild@0.24.0 -D,it works for me

I’m using yarn. A quick and dirty solution is:

  • cd node_modules/vite
  • rm -rf ./node_modules
  • edit package.json and change "esbuild": "^0.24.0", to "esbuild": "0.24.0",
  • run yarn install (inside the node_modules/vite folder)

I had the same issue and downgrading esbuild solved it.

npm i -D esbuild@0.24.0

I am confirming that I encountered the same issue just now.

Environment: NPM and Bun in Windows 11.

short term solution:

npm create vite@5

same issue here

Same issue here. I’ve tried 6.01, 6.02, and 6.04. I can confirm that the npm i -D esbuild@0.24.0 hot fix works for 6.04.

5.4.11 is the latest version that works without it. I had been creating fresh projects and running builds all day. This just happened within the last few hours.

Sys info: node v20.9.0 npm v10.9.0 MacOS 15.1.1

I encountered the same issue with Vite version 6.0.4 not running in development mode. As a workaround, I downgraded to version "vite": "^5.1.8", and the project ran successfully. It seems there may be compatibility issues with the latest version.