Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] Expected identifier but found "import" #14790

Closed
shinokada opened this issue Dec 20, 2024 · 15 comments
Closed

[ERROR] Expected identifier but found "import" #14790

shinokada opened this issue Dec 20, 2024 · 15 comments

Comments

@shinokada
Copy link

shinokada commented Dec 20, 2024

Describe the bug

After a fresh installation, running pnpm dev, pnpm test:e2e and pnpm build returns the following errors:
(This happens without running pnpm update as well.)

> playwright test

[WebServer] ✘ [ERROR] Expected identifier but found "import"
[WebServer] 
[WebServer]     (define name):1:0:
[WebServer]       1 │ import.meta.dirname
[WebServer]         ╵ ~~~~~~
[WebServer] 
[WebServer] ✘ [ERROR] Expected identifier but found "import"
[WebServer] 
[WebServer]     (define name):1:0:
[WebServer]       1 │ import.meta.filename
[WebServer]         ╵ ~~~~~~
[WebServer] 
[WebServer] ✘ [ERROR] Expected identifier but found "import"
[WebServer] 
[WebServer]     (define name):1:0:
[WebServer]       1 │ import.meta.url
[WebServer]         ╵ ~~~~~~
[WebServer] 
[WebServer] failed to load config from /Users/shinichiokada/Downloads/svelte/svelte-test/vite.config.ts
[WebServer] error during build:
[WebServer] Error: Build failed with 3 errors:
[WebServer] (define name):1:0: ERROR: Expected identifier but found "import"
[WebServer] (define name):1:0: ERROR: Expected identifier but found "import"
[WebServer] (define name):1:0: ERROR: Expected identifier but found "import"
[WebServer]     at failureErrorWithLog (/Users/shinichiokada/Downloads/svelte/svelte-test/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1476:15)
[WebServer]     at /Users/shinichiokada/Downloads/svelte/svelte-test/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:945:25
[WebServer]     at runOnEndCallbacks (/Users/shinichiokada/Downloads/svelte/svelte-test/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1316:45)
[WebServer]     at buildResponseToResult (/Users/shinichiokada/Downloads/svelte/svelte-test/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:943:7)
[WebServer]     at /Users/shinichiokada/Downloads/svelte/svelte-test/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:970:16
[WebServer]     at responseCallbacks.<computed> (/Users/shinichiokada/Downloads/svelte/svelte-test/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:622:9)
[WebServer]     at handleIncomingPacket (/Users/shinichiokada/Downloads/svelte/svelte-test/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:677:12)
[WebServer]     at Socket.readFromStdout (/Users/shinichiokada/Downloads/svelte/svelte-test/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:600:7)
[WebServer]     at Socket.emit (node:events:518:28)
[WebServer]     at addChunk (node:internal/streams/readable:561:12)
Error: Process from config.webServer was not able to start. Exit code: 1

Reproduction

npx sv create svelte-app
cd svelte-app
pnpm update
pnpm test:e2e

Logs

No response

System Info

npx envinfo --system --npmPackages svelte,rollup,webpack --binaries --browsers

   System:
    OS: macOS 15.2
    CPU: (10) arm64 Apple M2 Pro
    Memory: 81.20 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
    pnpm: 9.15.1 - /opt/homebrew/bin/pnpm
    bun: 1.1.8 - ~/.bun/bin/bun
  Browsers:
    Chrome: 131.0.6778.205
    Edge: 131.0.2903.112
    Safari: 18.2
  npmPackages:
    svelte: ^5.15.0 => 5.15.0 

Severity

blocking an upgrade

@shinokada shinokada changed the title [v5.15.0] Failed to load config from svelte-test/vite.config.ts [v5.15.0] Failed to load config from vite.config.ts Dec 20, 2024
@taariqelliott
Copy link

Thought I was the only one! I tried with pnpm & bun and couldn't understand what was going on until I realized creating a new project doesn't generate the .svelte-kit folder which seems to be the issue. Hopefully this gets fixed soon.

@yaman-cruise
Copy link

It's the second time this week that I've been blocked from working because Svelte doesn't work anymore. Who is responsible for QA? They should reduce the frequency of updates and focus more on stability.

@YosephBiniyam
Copy link

This just happed to me too, Glad I am not the only one.

@wiesson
Copy link

wiesson commented Dec 20, 2024

It's the second time this week that I've been blocked from working because Svelte doesn't work anymore. Who is responsible for QA? They should reduce the frequency of updates and focus more on stability.

What an inappropriate comment. I think an apology on your part would be nice.

@stephane-vanraes
Copy link
Contributor

This is due to some breaking changes introduced in the latest vite package
Drop the version of vite back to v5 and it should work again.

@spences10
Copy link
Member

@yaman-cruise take some time and read back what you put in your comment

You want to speak to the manager do you?

If you're unhappy you can always have your money back

@spences10
Copy link
Member

This is due to some breaking changes introduced in the latest vite package Drop the version of vite back to v5 and it should work again.

also @sveltejs/vite-plugin-svelte if you upgraded that to v5

@yaman-cruise
Copy link

You guys are right. Let's focus more on a workaround until it's fixed. But I see there is already one.

@dominikg
Copy link
Member

caused by a change in esbuild 0.24.1, evanw/esbuild#4010

workaround is to pin it to 0.24.0 via package.json resolutions or pnpm.overrides

@dominikg dominikg changed the title [v5.15.0] Failed to load config from vite.config.ts [ERROR] Expected identifier but found "import" Dec 20, 2024
@dominikg
Copy link
Member

also see sveltejs/cli#366

there is nothing to be done on the svelte side, just wait for it to be fixed and use 0.24.0 until then

@shinokada
Copy link
Author

shinokada commented Dec 20, 2024

For now running the following works for me:

pnpm add -D esbuild@=0.24.0
pnpm dedupe

@YosephBiniyam
Copy link

For now running the following works for me:

pnpm add -D esbuild@=0.24.0
pnpm dedupe

Thanks @shinokada, It worked for me.

@yaman-cruise
Copy link

Looks like [email protected] fixed this.

@dominikg
Copy link
Member

vite 6.0.5 pinned esbuild to 0.24.0, we are going to unpin esbuild after the fix has been released. this step has been taken to reduce the number of affected users and make it easier than adding a local override.

i'll close this issue as regular update flow get people out of it, still recommend interested parties to follow esbuild and vite release notes over the next hours/days.

@dominikg dominikg closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2024
@GuoDapeng
Copy link

evanw/esbuild#4010 (comment)

这个好用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants