0

I am using "angular2-highcharts": "0.4.1" library for using highcharts in angular2 framework. It was working correctly. If I try to delete node_modules and install using npm install afresh it gives below error to imports

[INFO] Module '"C:/Projects/SpectrumAnalyzer/test/Viavi Monitoring View/MonitorView/MonitorView/node_modules/@types/highcha rts/modules/exporting"' resolves to a non-module entity and cannot be imported using this construct.

[INFO] Module '"C:/Projects/SpectrumAnalyzer/test/Viavi Monitoring View/MonitorView/MonitorView/node_modules/@types/highcha rts/modules/offline-exporting"' resolves to a non-module entity and cannot be imported using this construct.

It fails at the import statement below

import * as HichartsExporting from 'highcharts/modules/exporting';
import * as HichartsOfflineExporting from 'highcharts/modules/offline-exporting';
HichartsExporting(Highcharts);
HichartsOfflineExporting(Highcharts);

I checked node_modules changes they have done below changes :

node_modules/@types/highcharts/modules/exporting.d.ts Before : declare var HighchartsExporting: (H: Static) => Static; After :

declare function HighchartsExporting(H: Static): Static;

and same in

node_modules/@types/highcharts/modules/offline-exporting.d.ts Before : declare var HighchartsOfflineExporting: (H: Static) => Static;

After :

declare function HighchartsOfflineExporting(H: Static): Static;

Kindly suggest.

Thanks, Sardar Nale

Coder Guru
  • 513
  • 3
  • 18
  • 37

1 Answers1

0

I hope it isn't too late. I just asked a similar question.

If require works fine for you, you could try

import HichartsExporting = require('highcharts/modules/exporting');
import HichartsOfflineExporting = require('highcharts/modules/offline-exporting');
HichartsExporting(Highcharts);
HichartsOfflineExporting(Highcharts);

In my specific case, the only way I could do it, after hours researching, was by giving up on the imports and including the script tags in the HTML:

<script src="~/node_modules/highcharts/modules/exporting.js">
<script src="~/node_modules/highcharts/modules/offline-exporting.js">

In this case, you don't even have to do

HichartsExporting(Highcharts);
HichartsOfflineExporting(Highcharts);

afterwards.

coconochao
  • 141
  • 7