ant-design-charts icon indicating copy to clipboard operation
ant-design-charts copied to clipboard

Next js problem with @ant-design/charts, error location: node_modules\@antv\x6-react-components\es\toolbar\item.js

Open kostazol opened this issue 2 years ago • 8 comments

I got error on compile

./node_modules/antd/es/popover/style/index.css Global CSS cannot be imported from within node_modules. Read more: https://nextjs.org/docs/messages/css-npm Location: node_modules@antv\x6-react-components\es\color-picker\index.js

Import trace for requested module: ./node_modules/@antv/x6-react-components/es/color-picker/index.js ./node_modules/@antv/x6-react-components/es/index.js ./node_modules/@antv/xflow-extension/es/canvas-context-menu/components/index.js ./node_modules/@antv/xflow-extension/es/canvas-context-menu/index.js ./node_modules/@antv/xflow-extension/es/index.js ./node_modules/@ant-design/flowchart/es/index.js ./node_modules/@ant-design/charts/es/index.js ./features/nodeInfo/view/NodeChart/NodeChart.tsx ./features/nodeInfo/index.tsx ./modules/HomePage/HomePage.tsx ./modules/index.ts ./pages/index.tsx

I don't have this error on version 1.1.16, and I have this error on version 1.3.6

kostazol avatar Apr 20 '22 06:04 kostazol

Same issue with 1.3.6

williampeterpaul avatar Apr 22 '22 14:04 williampeterpaul

Related to @antv/g2 version 4.2.0, manually installing that sub-package at version 4.1.50 fixed

williampeterpaul avatar Apr 22 '22 16:04 williampeterpaul

For anyone else experiencing this issue, remember to persist an updated package-lock.json file to fix any failing builds. This one caught me out.

williampeterpaul avatar May 04 '22 15:05 williampeterpaul

Hi @williampeterpaul,

I'm getting this error. Could you please explain the solution in a simplified manner? Noob here.

devgurbir avatar May 22 '22 14:05 devgurbir

@devgurbir

@ant-design/charts requires @ant/g2 but the latest version (4.2.0) of g2 seems to be causing this issue. By manually installing an older version of g2 (4.1.50) and rebuilding the dependency tree (delete package-lock) you can temporarily circumvent the issue

williampeterpaul avatar May 22 '22 14:05 williampeterpaul

@williampeterpaul Had to mess around a bit but it worked eventually :)

Thank you so much.

devgurbir avatar May 22 '22 15:05 devgurbir

@devgurbir No problem man, glad I could help.

williampeterpaul avatar May 24 '22 00:05 williampeterpaul

Please repair this bug as soon as possible

showarp avatar May 24 '22 11:05 showarp

The problem lies in @ant-design/flowchart, it is recommended to use subpackages or configure:

import dynamic from "next/dynamic";
const Line = dynamic(
  () => import("@ant-design/charts").then((mode) => mode.Line),
  { ssr: false }
);

lxfu1 avatar Jan 17 '23 02:01 lxfu1