Home forums Using CanvasJS CanvasJS with Electron/Node.js

Tagged: ,

This topic contains 2 replies, has 2 voices, and was last updated by  Priyanka M S 4 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #21240

    DanielSore
    Member

    Hi,

    I’m trying to use CanvasJS with Electron, but I’m getting the bellow error:

    A JavaScript error occurred in the main process
    Uncaught Exception:
    import CanvasJS from ‘canvasjs’;
    ^^^^^^

    SyntaxError: Unexpected token import

    In my code, I’m requiring CanvasJS as below:

    var CanvasJS = require(‘canvasjs’);

    Is there a workaround to solve this issue?

    Best regards

    #21257

    DanielSore
    Member

    Solved!

    Since Electron doesn’t support ES6 syntaxes, I used babel to convert from ES6 to CommonJS.

    Anyway, there is a error on npm module in the following file:

    node_modules/canvasjs/src/charts/index.js

    The “export” syntaxes must be changed to “import”.

    Best regards

    #21258

    Priyanka M S
    Member

    @danielsore,

    Glad that you figured out.
    Using var CanvasJS = require('./canvasjs.min') should work fine. Here is a working sample.

    __
    Priyanka M S
    Team CanvasJS

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

You must be logged in to reply to this topic.