Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Module not found: Error: Can't resolve 'highcharts' #247

Open
AbdurRehman91 opened this issue Dec 8, 2017 · 2 comments
Open

Module not found: Error: Can't resolve 'highcharts' #247

AbdurRehman91 opened this issue Dec 8, 2017 · 2 comments

Comments

@AbdurRehman91
Copy link

AbdurRehman91 commented Dec 8, 2017

Hi,I am using angular 4 and trying to use high charts in angular4 and highchart verison is 0.5.5.
But i am facing this issue

Module not found: Error: Can't resolve 'highcharts' Module not found: Error: Can't resolve 'highcharts/modules/exporting'
My app.modules.ts file contains the following
`import {ChartModule} from 'angular2-highcharts';
import {HighchartsStatic} from 'angular2-highcharts/dist/HighchartsService';

declare var require: any;
export function highchartsFactory()
{
const hc = require('highcharts');
const dd = require('highcharts/modules/exporting');
dd(hc);
return hc;
//return highcharts;
}

@NgModule({

 imports:[
 ChartModule,
//ChartModule.forRoot(require('highcharts')),
],
providers: [
{
    provide: HighchartsStatic,
    useFactory: highchartsFactory
}

],

}

P.S:I have tried all the solutions(related to this issue) being discussed in this repo,but still the issue is not resloved.

thanks

@abhiyg
Copy link

abhiyg commented Dec 12, 2017

Below code worked for me:
app.module.ts
import { ChartModule } from 'angular2-highcharts';
import { HighchartsStatic } from 'angular2-highcharts/dist/HighchartsService';
declare var require: any;
export function highchartsFactory() {
return require('highcharts');
}

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,ChartModule],
providers: [
{
provide: HighchartsStatic,
useFactory: highchartsFactory
}
],
bootstrap: [AppComponent]
})
export class AppModule { }

Add the below on top of your Polyfills.ts to:
import 'zone.js';
import 'reflect-metadata';

@rijine
Copy link

rijine commented Dec 14, 2017

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants