Home › forums › Using CanvasJS › Uncaught SyntaxError: Unexpected token import
This topic contains 2 replies, has 3 voices, and was last updated by Indranil Deo 10 months, 3 weeks ago.
I’m getting a “Uncaught SyntaxError: Unexpected token import”-error when I import CanvasJS in my react project.
I import it via import CanvasJS from 'canvasjs'
import CanvasJS from 'canvasjs'
The console says thats the part where the error occurs:
import Charts from '../core/charts';
Adding type=”text/babel” to the src attribute of script tag should work fine. Please refer this stackoverflow thread for more info. If this doesn’t solve the issue, kindly share sample project so that we can look into the code and help you out.
Also please take a look at this jsfiddle on rendering Column Chart using ReactJS.
We have just released v2.1 with module import/export with which you can easily integrate front-end framework like React, Angular, Vuejs, etc. Please refer to the release blog for more information. Do download the latest version from our download page and let us know your feedback.
You must be logged in to reply to this topic.