user3570465
user3570465

Reputation: 1

Issue with npm and Highcharts

I am trying to install high-charts through npm and use it on the server side to output the data to a jade template. I am using basic express framework.

The first section in the link below is the guide that I am following.

http://www.highcharts.com/docs/getting-started/install-from-npm

However I am getting an error when I use this line of code

require('highcharts/modules/exporting')(Highcharts);

I have tried this across multiple computers and it's the same error across all.

Code used:

Code used

I have no idea why its failing. Any help would be great.

Upvotes: 0

Views: 582

Answers (1)

Mono
Mono

Reputation: 392

The problem is that you are trying to use Highcharts on the server side, but that library requires DOM nodes from the client's HTML document to work (like the document object from the error you show and also the container where the chart will be drawn).

You can emulate the client side using PhantomJS. This way you can render your charts on the server. You can try following this guide from Highcharts documentation website.

However, it's definitely easier to load and use the library on the client side and use the server only to send the chart data to the client.

Upvotes: 1

Related Questions