Skip to content

"Unexpected token" error when there's no syntax error #1105

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

Open
Keshav-writes-code opened this issue Apr 4, 2025 · 1 comment
Open

"Unexpected token" error when there's no syntax error #1105

Keshav-writes-code opened this issue Apr 4, 2025 · 1 comment
Labels
awaiting submitter bug Something isn't working triage Awaiting triage by a project member

Comments

@Keshav-writes-code
Copy link

Keshav-writes-code commented Apr 4, 2025

Describe the bug

Hi, I am using Astrojs with the @astrojs/svelte integration installed

i Sometimes expereince Unexpected token when everything about the syntax is completely fine

for example
in this svelte component, i am importing some other compoennts

<script lang="ts">
import { onMount } from "svelte";
import SignupForm from "./Signup_form.svelte";
import CardSignupReqSentSuccessfully from "./card_signup_req_sent_successfully.svelte";

but the vite-plugin-svelte from astro dev server logs, says :-

  vite:load 0.39ms [fs] /src/components/auth/Signup_component.svelte +10ms
  astro:vite Error when evaluating SSR module /home/keshav/Programming Stuff/Projects/WebDevProjects/humanityAnalytics/src/pages/signup.astro: src/components/auth/Signup_component.svelte:3:9 Unexpected token
  astro:vite https://svelte.dev/e/js_parse_error
  astro:vite   Plugin: vite-plugin-svelte
  astro:vite   File: src/components/auth/Signup_component.svelte:3:9
  astro:vite    1 |  <script lang="ts">
  astro:vite    2 |    import { onMount } from "svelte";
  astro:vite    3 |    import SignupForm from "./Signup_form.svelte";
  astro:vite                  ^
  astro:vite    4 |    import CardSignupReqSentSuccessfully from "./card_signup_req_sent_successfully.svelte";
  astro:vite    5 |    let isReqSent = $state(false); +0ms
21:49:20 [ERROR] src/components/auth/Signup_component.svelte:3:9 Unexpected token
https://svelte.dev/e/js_parse_error
  Location:

i tried rm rfed the project directory and clone my codebase repo again and fresh installed all packages node packages. but still got the same error.

Edit!

  • comes out, it was a lockerfile issue that made vite svelte plugin misbehave. i messed up my bun locker file and installed the packages incorrectly.
  • to fix i deleted the locker file then installed packages and then it was solved! phew! couldn't had been less cluefull

Reproduction URL

its not possible to be reproduced or atleast i have no clue how would i reproduce it

Reproduction

No response

Logs

vite:load 0.39ms [fs] /src/components/auth/Signup_component.svelte +10ms
  astro:vite Error when evaluating SSR module /home/keshav/Programming Stuff/Projects/WebDevProjects/humanityAnalytics/src/pages/signup.astro: src/components/auth/Signup_component.svelte:3:9 Unexpected token
  astro:vite https://svelte.dev/e/js_parse_error
  astro:vite   Plugin: vite-plugin-svelte
  astro:vite   File: src/components/auth/Signup_component.svelte:3:9
  astro:vite    1 |  <script lang="ts">
  astro:vite    2 |    import { onMount } from "svelte";
  astro:vite    3 |    import SignupForm from "./Signup_form.svelte";
  astro:vite                  ^
  astro:vite    4 |    import CardSignupReqSentSuccessfully from "./card_signup_req_sent_successfully.svelte";
  astro:vite    5 |    let isReqSent = $state(false); +0ms
21:49:20 [ERROR] src/components/auth/Signup_component.svelte:3:9 Unexpected token
https://svelte.dev/e/js_parse_error
  Location:

System Info

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (12) x64 Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz
    Memory: 4.39 GB / 11.60 GB
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.config/nvm/versions/node/v22.14.0/bin/node
    npm: 10.9.2 - ~/.config/nvm/versions/node/v22.14.0/bin/npm
    bun: 1.2.5 - ~/.bun/bin/bun
@Keshav-writes-code Keshav-writes-code added bug Something isn't working triage Awaiting triage by a project member labels Apr 4, 2025
@Keshav-writes-code Keshav-writes-code changed the title Unexpected token when there's no syntax error "Unexpected token" error when there's no syntax error Apr 4, 2025
@Conduitry
Copy link
Member

If it can't be reproduced, then it can't be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter bug Something isn't working triage Awaiting triage by a project member
Projects
None yet
Development

No branches or pull requests

2 participants