react-financial-charts icon indicating copy to clipboard operation
react-financial-charts copied to clipboard

Unexpected token 'export'

Open viviando1110 opened this issue 1 year ago • 4 comments

I'm submitting a...

  • [x ] bug
  • [ ] feature
  • [ ] chore

What is the current behavior

cannot build, Unexpected token 'export'

What is the expected behavior

can build using example code

Please tell us about your environment

  • Version: 2.0.1
  • Browser: [all | Chrome XX | Firefox XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari ]

Other information

Getting this error:

rts/lib/index.js:1 export * from "@react-financial-charts/annotations"; ^^^^^^

SyntaxError: Unexpected token 'export' at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1195:20) at Module._compile (node:internal/modules/cjs/loader:1239:27) at Module._extensions..js (node:internal/modules/cjs/loader:1329:10) at Module.load (node:internal/modules/cjs/loader:1133:32) at Module._load (node:internal/modules/cjs/loader:972:12) at Module.require (node:internal/modules/cjs/loader:1157:19) at require (node:internal/modules/helpers:119:18)

I'm using Typescript 5.0.2 and react 18.2.0, node 19

Is this combination supported? Or should I use a different version?

viviando1110 avatar May 22 '23 04:05 viviando1110

I get this same error when trying to build using next.js 12 and react 18.

andyevers avatar Jun 06 '23 10:06 andyevers

if you are using next.js use dynamic imports like this.

const CandleChart = dynamic(() => import("components/charts/CandleChart"), {
  ssr: false,
});

turtlemana avatar Aug 08 '23 12:08 turtlemana

This is because this library doesn't support commonjs, it only supports ESM.

abforce avatar Aug 17 '23 14:08 abforce

if you are using next.js use dynamic imports like this.

const CandleChart = dynamic(() => import("components/charts/CandleChart"), {
  ssr: false,
});

Can i ask what's your next.js version? Because I tried your solution, still can't build the project. But it works when dev mode

newddobi avatar May 20 '24 07:05 newddobi