-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Unexpected token 'export' #6312
Comments
以下的 Issues 可能会帮助到你 / The following issues may help you
|
I am experiencing the same issue and because of this problem, it is difficult to move from v4 to v5. If I import like this, import { PageHeader } form '@ant-design/pro-layout' I got If I import like this, import { PageHeader } form '@ant-design/pro-components' I got @chenshuai2144 but you says
which one is right?? |
Having the same issue. I can get past the
This however gives me another error: |
I'm very sorry, I didn't see that you are using next.js, we only provide the es version of js, do you need to configure a special conversion tool in next.js? |
I found this, can it help you? https://stackoverflow.com/questions/65936222/next-js-syntaxerror-unexpected-token-export |
@chenshuai2144 |
The suggestion from @chenshuai2144 is correct. However it is quite some puzzling to get it done. You actually need to trace which things have to be transpiled. In this case only @ant-design/pro-components is far from enough. I got it working with the following in my next.config:
But I guess other projects need more modules to be transpiled as they use other components from antd and/or ant-design/pro. When running you actually can get a good idea of what to include in the transpile step next. This was my last error that indicated I should add 'rc-picker' as well:
|
Waiting for a fix too. my issue is with JEST. I found a bypass using PageHeader from antd 4 while the rest of my app is on antd 5 Install via : Then I can use : import './pageHeaderCssPatch.css';
import { PageHeader } from 'antd-4'; |
I had a NextJS project throwing this error. As a workaround, instead of using: import { CodeFilled } from '@ant-design/icons'; This worked: import CodeFilled from '@ant-design/icons/CodeFilled'; |
🐛 Bug
Cannot use
PageHeader
component in my project because when I try to import it, I'm gettingUnexpected token 'export' at '.../node_modules/ant-design/pro-components/es/index.js:1'
error📷 Reproduce
here is a codesandbox example I've made.
run npm run dev and you'll see in console the error
🏞 Expected
The component should be imported without errors
© Version
"@ant-design/pro-components": "^2.3.35"
Google Chrome browser
mac OS
#6280
The text was updated successfully, but these errors were encountered: