Home › forums › Using CanvasJS › CanvasJS with Electron/Node.js
Tagged: canvasjs, nodejs
This topic contains 2 replies, has 2 voices, and was last updated by Priyanka M S 1 year, 2 months ago.
I’m trying to use CanvasJS with Electron, but I’m getting the bellow error:
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?
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:
The “export” syntaxes must be changed to “import”.
Glad that you figured out.
Using var CanvasJS = require('./canvasjs.min') should work fine. Here is a working sample.
var CanvasJS = require('./canvasjs.min')
Priyanka M S
You must be logged in to reply to this topic.