gevgeny / angular2-highcharts

:bar_chart: :chart_with_upwards_trend: Highcharts for your Angular project
MIT License
381 stars 113 forks source link

ERROR in src/app/app.module.ts(71,25): error TS2304: Cannot find name 'require'. #249

Open dongzhouT opened 6 years ago

dongzhouT commented 6 years ago

this is my 'app.module.ts' imports: [ BrowserModule, FormsModule, ChartModule.forRoot(require('highcharts')) ], when i run 'ng serve',show the error->'ERROR in src/app/app.module.ts(71,25): error TS2304: Cannot find name 'require'.' How can I do to fix it?

gargantuanprism commented 6 years ago

you can add declare var require: any to src/typings.d.ts, but it'll still fail when you try to build for production.

fabian-hesse-swarco commented 6 years ago

and there is no valid way for production / packaging? I am using ng-packagr to pack my modules and it fails because of this very unconvenient way with a require function inside forRoot:

ChartModule.forRoot(require('highcharts/highstock'))