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

Uncaught SyntaxError: Cannot use import statement outside a module #21094

Closed
1 task done
wangytangy opened this issue Jan 23, 2020 · 7 comments
Closed
1 task done

Uncaught SyntaxError: Cannot use import statement outside a module #21094

wangytangy opened this issue Jan 23, 2020 · 7 comments
Labels
🤔 Need Reproduce We cannot reproduce your problem

Comments

@wangytangy
Copy link

wangytangy commented Jan 23, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://spectrum.chat/next-js/general/the-problem-in-integrating-next-js-with-ant-ui-when-customizing-ant-themes~bdc65d8d-ad92-4ec0-8469-f31269b85bc6

Steps to reproduce

import Button from 'antd/es/button';

render () {
  return (<Button />);
}

What is expected?

The button should render correctly.

What is actually happening?

The webpage cannot load because of a Javascript syntax error: "Uncaught SyntaxError: Cannot use import statement outside a module"

The webpack bundle shows the error here:

/***/ (function(module, exports) {

import Button from './button'; // <----- ERROR
import ButtonGroup from './button-group';
Button.Group = ButtonGroup;
export default Button;
//# sourceMappingURL=index.js.map

/***/ }),

Environment Info
antd 3.26.7
React 16.8.4
System macOS High Sierra v0.13.6
Browser Chrome Version 79.0.3945.88
@zombieJ zombieJ added the 🤔 Need Reproduce We cannot reproduce your problem label Jan 24, 2020
@ant-design-bot
Copy link
Contributor

Hello @wangytangy. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro or a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 7 days.

你好 @wangytangy, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。7 天内未跟进的 issue 将会被自动关闭。

@ant-design-bot
Copy link
Contributor

This issue is closed because it has been marked as Need Reproduce, but has not had recent activity.
If you can provide a reproduce, feel free to ping anyone of our maintainers to reopen this issue.
Thank you for your contributions.

@arvinsim
Copy link

arvinsim commented Feb 10, 2020

I have the same problem as above. Similar issue to #13620

For CRA + Ant Design, I thought that component testing work out of the box.

@arvinsim
Copy link

@wangytangy This is a solution that worked for me.

@patelrikin
Copy link

@arvinsim are you able to post any snippet here since the link that you shared is 404'ing and possibly external links may not be counted on in terms of availability in future.

@irux
Copy link

irux commented Oct 27, 2020

@arvinsim could you post your solution again? I can't see the link you posted.

@Jplus2
Copy link

Jplus2 commented Aug 9, 2022

How to solve this for cases not using babel? using ts-jest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 Need Reproduce We cannot reproduce your problem
Projects
None yet
Development

No branches or pull requests

7 participants