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

[bug] ERROR: Expected identifier but found "import" #12015

Open
jn-novasol opened this issue Dec 20, 2024 · 2 comments
Open

[bug] ERROR: Expected identifier but found "import" #12015

jn-novasol opened this issue Dec 20, 2024 · 2 comments
Labels
status: needs triage This issue needs to triage, applied to new issues status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes type: bug

Comments

@jn-novasol
Copy link

Describe the bug

First time trying Tauri and there is a problem with the basic app it seems like:
failed to load config from /tmp/tauri-app/vite.config.ts
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"

Reproduction

/tmp ❯ sh <(curl https://create.tauri.app/sh)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16121 100 16121 0 0 136k 0 --:--:-- --:--:-- --:--:-- 138k
info: downloading create-tauri-app
✔ Project name · tauri-app
✔ Identifier · com.tauri-app.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)
✔ Choose your package manager · deno
✔ Choose your UI template · Vanilla
✔ Choose your UI flavor · TypeScript

Template created! To get started run:
cd tauri-app
deno install
deno task tauri android init

For Desktop development, run:
deno task tauri dev

For Android development, run:
deno task tauri android dev

/tmp took 9s ❯ cd tauri-app
/tmp/tauri-app via  v20.11.1 ❯ deno install
/tmp/tauri-app via  v20.11.1 ❯ deno task tauri dev
Task tauri tauri "dev"
Running BeforeDevCommand (deno task dev)
Task dev 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 /tmp/tauri-app/vite.config.ts
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 (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:1476:15)
at file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:945:25
at runOnEndCallbacks (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:1316:45)
at buildResponseToResult (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:943:7)
at file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:970:16
at responseCallbacks. (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:622:9)
at handleIncomingPacket (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:677:12)
at Readable.readFromStdout (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:600:7)
at Readable.emit (ext:deno_node/_events.mjs:393:28)
at addChunk (ext:deno_node/_stream.mjs:2438:16)
Error The "beforeDevCommand" terminated with a non-zero status code.

Expected behavior

That starter app runs on localhost

Full tauri info output

/tmp ❯ sh <(curl https://create.tauri.app/sh)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16121  100 16121    0     0   136k      0 --:--:-- --:--:-- --:--:--  138k
info: downloading create-tauri-app
✔ Project name · tauri-app
✔ Identifier · com.tauri-app.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)
✔ Choose your package manager · deno
✔ Choose your UI template · Vanilla
✔ Choose your UI flavor · TypeScript

Template created! To get started run:
  cd tauri-app
  deno install
  deno task tauri android init

For Desktop development, run:
  deno task tauri dev

For Android development, run:
  deno task tauri android dev

/tmp took 9s ❯ cd tauri-app
/tmp/tauri-app via  v20.11.1 ❯ deno install
/tmp/tauri-app via  v20.11.1 ❯ deno task tauri dev
Task tauri tauri "dev"
    Running BeforeDevCommand (`deno task dev`)
Task dev 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 /tmp/tauri-app/vite.config.ts
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 (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:1476:15)
    at file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:945:25
    at runOnEndCallbacks (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:1316:45)
    at buildResponseToResult (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:943:7)
    at file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:970:16
    at responseCallbacks.<computed> (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:622:9)
    at handleIncomingPacket (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:677:12)
    at Readable.readFromStdout (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:600:7)
    at Readable.emit (ext:deno_node/_events.mjs:393:28)
    at addChunk (ext:deno_node/_stream.mjs:2438:16)
    Error The "beforeDevCommand" terminated with a non-zero status code.

Stack trace

/tmp ❯ sh <(curl https://create.tauri.app/sh)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16121  100 16121    0     0   136k      0 --:--:-- --:--:-- --:--:--  138k
info: downloading create-tauri-app
✔ Project name · tauri-app
✔ Identifier · com.tauri-app.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)
✔ Choose your package manager · deno
✔ Choose your UI template · Vanilla
✔ Choose your UI flavor · TypeScript

Template created! To get started run:
  cd tauri-app
  deno install
  deno task tauri android init

For Desktop development, run:
  deno task tauri dev

For Android development, run:
  deno task tauri android dev

/tmp took 9s ❯ cd tauri-app
/tmp/tauri-app via  v20.11.1 ❯ deno install
/tmp/tauri-app via  v20.11.1 ❯ deno task tauri dev
Task tauri tauri "dev"
    Running BeforeDevCommand (`deno task dev`)
Task dev 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 /tmp/tauri-app/vite.config.ts
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 (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:1476:15)
    at file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:945:25
    at runOnEndCallbacks (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:1316:45)
    at buildResponseToResult (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:943:7)
    at file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:970:16
    at responseCallbacks.<computed> (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:622:9)
    at handleIncomingPacket (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:677:12)
    at Readable.readFromStdout (file:///tmp/tauri-app/node_modules/.deno/esbuild@0.24.1/node_modules/esbuild/lib/main.js:600:7)
    at Readable.emit (ext:deno_node/_events.mjs:393:28)
    at addChunk (ext:deno_node/_stream.mjs:2438:16)
    Error The "beforeDevCommand" terminated with a non-zero status code.

Additional context

No response

@jn-novasol jn-novasol added status: needs triage This issue needs to triage, applied to new issues type: bug labels Dec 20, 2024
@nielsvanee
Copy link

It is an issue with Vite 6, I fixed it by downgrading the dependency to vite@5.4.10

@jvhuaiying
Copy link

I'm also having the same issue

@FabianLars FabianLars added the status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes type: bug
Projects
None yet
Development

No branches or pull requests

4 participants