-
Notifications
You must be signed in to change notification settings - Fork 354
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] Cannot use import statement outside a module #215
Comments
你复现代码有问题, import React, { useState, useEffect } from "react". |
暂时的解决方案 用下面的代码替换掉第四行
|
忘记说这个是个component了,如果单独作为page确实要这行 |
I'm also having this problem with latest version of Next.js and ant-design-charts using the examples from docs. |
Try my solution |
@leebang your solution worked. Tho i am using NextJs and I still get the same error at the build time( |
Hi guys, a hack solution to this is to find the module you want to use in @ant-design/charts and copy it out of node modules and into some place else like /components. So if you want to use the Column module, you just copy the module and create a file like /components/column.js |
Hi Lee, |
|
@ya-s-u ha, didn't notice that nextjs feature - works like a charm! thanks a lot! |
🐛 bug 描述 [详细地描述 bug,让大家都能理解]
尝试在NextJS中使用chart,报错
📷 复现步骤 [清晰描述复现步骤,让别人也能看到问题]
根据官网步骤安装部署
https://charts.ant.design/demos/line/#%E9%80%9A%E8%BF%87%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0%E6%8C%87%E5%AE%9A%E6%8A%98%E7%BA%BF%E9%A2%9C%E8%89%B2
🏞 期望结果 [描述你原本期望看到的结果]
出现demo中的图表
💻 复现代码 [提供可复现的代码,仓库,或线上示例]
import { InfoCircleOutlined } from "@ant-design/icons"
import { Tooltip } from "antd"
import { useState, useEffect } from "react"
import { Line } from "@ant-design/charts"
export const ScoreChart = (props: {}) => {
const data = [
{ year: "1991", value: 3 },
{ year: "1992", value: 4 },
{ year: "1993", value: 3.5 },
{ year: "1994", value: 5 },
{ year: "1995", value: 4.9 },
{ year: "1996", value: 6 },
{ year: "1997", value: 7 },
{ year: "1998", value: 9 },
{ year: "1999", value: 13 }
]
const config = {
data,
xField: "year",
yField: "value"
}
return (
<Line {...config} />
)
}
© 版本信息
🚑 其他信息 [如截图等其他信息可以贴在这里]
Server Error
SyntaxError: Cannot use import statement outside a module
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
/Users/xxx/Documents/WORK/xxx/node_modules/ (antv/g6/es/index.js (1)
wrapSafe
internal/modules/cjs/loader.js (1060:16)
Module._compile
internal/modules/cjs/loader.js (1108:27)
Module._extensions..js
internal/modules/cjs/loader.js (1164:10)
The text was updated successfully, but these errors were encountered: