Home Forums Chart Support Uncaught SyntaxError: Unexpected token import

Uncaught SyntaxError: Unexpected token import

Viewing 3 posts - 1 through 3 (of 3 total)
  • #17330


    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'

    The console says thats the part where the error occurs:

    import Charts from '../core/charts';



    We have released React Component for Charts using which you can build charts in react way. Please refer to this blog post for release note.


    Adding type=”text/babel” to the src attribute of script tag should work fine. Please refer this stackoverflow thread for more information.

    If you are still facing issue, kindly create sample project reproducing the issue you are facing and share with us over Google-Drive or Onedrive so that we can run it locally to understand the scenario better and help you out.

    Also please take a look at this JSFiddle for an example on rendering Column Chart using ReactJS.
    Column Chart in React

    Vishwas R
    Team CanvasJS

    • This reply was modified 1 year, 2 months ago by Vishwas R.


    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.

    Indranil Deo,
    Team CanvasJS

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.