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" #4010

Closed
ti777777 opened this issue Dec 20, 2024 · 22 comments
Closed

ERROR: Expected identifier but found "import" #4010

ti777777 opened this issue Dec 20, 2024 · 22 comments

Comments

@ti777777
Copy link

Describe what esbuild is doing incorrectly and what it should be doing instead.

When using Vite to create a new project, it fails to start properly. Downgrading esbuild to version 0.24.0 resolves the issue.

OS: Windows 10
Node.js Version: v22.12.0

PS C:\react-app> npm run dev

react-app@0.0.0 dev
vite

X [ERROR] Expected identifier but found "import"

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

X [ERROR] Expected identifier but found "import"

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

X [ERROR] Expected identifier but found "import"

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

failed to load config from C:\react-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 (C:\react-app\node_modules\esbuild\lib\main.js:1476:15)
at C:\react-app\node_modules\esbuild\lib\main.js:945:25
at runOnEndCallbacks (C:\react-app\node_modules\esbuild\lib\main.js:1316:45)
at buildResponseToResult (C:\react-app\node_modules\esbuild\lib\main.js:943:7)
at C:\react-app\node_modules\esbuild\lib\main.js:970:16
at responseCallbacks. (C:\react-app\node_modules\esbuild\lib\main.js:622:9)
at handleIncomingPacket (C:\react-app\node_modules\esbuild\lib\main.js:677:12)
at Socket.readFromStdout (C:\react-app\node_modules\esbuild\lib\main.js:600:7)
at Socket.emit (node:events:524:28)
at addChunk (node:internal/streams/readable:561:12)

@woohs
Copy link

woohs commented Dec 20, 2024

+1
I have the same problem.

@hi-ogawa
Copy link
Contributor

Vite uses define: { 'import.meta.url': 'xxx' } and it was working on 0.24.0, but it looks like this is now an error on 0.24.1
https://esbuild.github.io/try/#YgAwLjI0LjEAewogIGRlZmluZTogeyAnaW1wb3J0Lm1ldGEudXJsJzogJyJoZWxsbyInIH0KfQBlAGVudHJ5LmpzAGNvbnNvbGUubG9nKGltcG9ydC5tZXRhLnVybCk

@suhailkc
Copy link

npm i -D esbuild@0.24.0

@ffimnsr
Copy link

ffimnsr commented Dec 20, 2024

Happening to me as well, it broke the whole vite builds even the latest one. So, locking to version 0.24.0 temporarily fixes this.

@yeyunwen
Copy link

  1. 在项目的 package.json 中添加 resolutions 字段(如果你使用的是 pnpm 或 yarn):
{
  // ... 其他配置 ...
  "resolutions": {
    "esbuild": "0.24.0"
  }
}
  1. 更新依赖:运行以下命令以更新依赖并应用 resolutions:
    pnpm i

@SerkanSipahi
Copy link

@yeyunwen works for me. Thanks.

@wisnunugroho21
Copy link

+1
0.24.1 version cause an error for vite

@peshoicov
Copy link

I had this problem with both bun and node based projects, but installing esbuild 0.24.0 solved it only in the node based projects ... :(

@Priyam7295
Copy link

npm i -D esbuild@0.24.0

This worked for me.

@Prashanthbadri112
Copy link

npm i -D esbuild@0.24.0

This works fine for me

@sansuiblog
Copy link

npm i -D esbuild@0.24.0

thanks

@5lon
Copy link

5lon commented Dec 20, 2024

Big shot, awesome. That's perfect
Perfectly solve problems

@jeff-fe
Copy link

jeff-fe commented Dec 20, 2024

vitejs/vite#19024

@axolo
Copy link

axolo commented Dec 20, 2024

#10 64.72 ✘ [ERROR] Expected identifier but found "import"
#10 64.72       1 │ import.meta.dirname
#10 64.72         ╵ ~~~~~~

@Aduwoayooluwa
Copy link

npm i -D esbuild@0.24.0

This worked for me. Thank you. 0.24.1 breaks vite builds

@Vishnu-Siva-B
Copy link

npm i -D esbuild@0.24.0

This works but why this happens

Jazza-231 added a commit to scratchaddons-community/suggestions that referenced this issue Dec 20, 2024
@codecraftwt
Copy link

I am getting the same error. I have downgraded the version of esbuild to 0.24.0, but I am still encountering the error while deploying the React + Vite project on Render.

Screenshot_1

@Thyran
Copy link

Thyran commented Dec 20, 2024

Same error using tsup

npm i -D esbuild@0.24.0

Also worked for me. Hopefully they fix this quickly

@evanw evanw closed this as completed in 947f99f Dec 20, 2024
alessiofrittoli added a commit to alessiofrittoli/url-utils that referenced this issue Dec 20, 2024
build errors with `esbuild@0.24.1` - see issue evanw/esbuild#4010

(cherry picked from commit 2d5cfe94540b0e7da2749b9e8773d896b9d1827e)
alessiofrittoli added a commit to alessiofrittoli/url-utils that referenced this issue Dec 20, 2024
* bump: add `esbuild@0.24.0` to solve build errors (#14)

build errors with `esbuild@0.24.1` - see issue evanw/esbuild#4010

(cherry picked from commit 2d5cfe94540b0e7da2749b9e8773d896b9d1827e)

* fix: regenerated `pnpm-lock.yaml` file
alessiofrittoli added a commit to alessiofrittoli/exception that referenced this issue Dec 21, 2024
build errors with `esbuild@0.24.1` - see issue evanw/esbuild#4010

(cherry picked from commit 2d5cfe94540b0e7da2749b9e8773d896b9d1827e)
alessiofrittoli added a commit to alessiofrittoli/exception that referenced this issue Dec 21, 2024
* chore: minor improvements (#11)

(cherry picked from commit 95cc6864758dc20a98f225a6f0d355e0dd52a2f2)

* feature: add `jest` coverage file serving (#12)

(cherry picked from commit 8cbde6366f3880c971d959b14c63391fbd923b6d)

* fix: add `coverage` folder to ESLint ignored paths to avoid unnecessary warnings/errors (#13)

(cherry picked from commit df6b7015840ab5a17d5d547547f961da75d414f2)

* bump: add `esbuild@0.24.0` to solve build errors (#14)

build errors with `esbuild@0.24.1` - see issue evanw/esbuild#4010

(cherry picked from commit 2d5cfe94540b0e7da2749b9e8773d896b9d1827e)

* chore: regenerated `pnpm-lock.yaml` file
@talhatayyab
Copy link

https://stackoverflow.com/a/79301134/13086128

kepennar added a commit to Agado-dev/stencil-design-system that referenced this issue Jan 1, 2025
@mustafa0x
Copy link

@amankumarnayak kindly stop spamming 30+ people. thanks.

@mustafa0x
Copy link

This issue has already been solved. That is why it is closed. Simply update your dependencies.

@amankumarnayak
Copy link

Sorry my bad, i am actually new to it so i missed it , i will delete my post Thanks

kepennar added a commit to Agado-dev/stencil-design-system that referenced this issue Jan 3, 2025
fix(esbuild): issues with evanw/esbuild#4010

agado components

feat(components): implement button and link component from design

feat(apps): integrade button and link in example apps

chore(cleanup): remove old components

feat(storybook): add some branding in storybook using the manager

fix(angular): config

feat(button): add a custom longPress event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.