Skip to content

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

Closed as not planned
@Keshav-writes-code

Description

@Keshav-writes-code

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions