Search code examples
angularhighchartsangular2-highcharts

Getting error when using angular2-highcharts in angular2 project


I am using angular 2 and angular2-highcharts in my project. this is my app.component.ts file

import { Component } from 'angular2/core';
import { CHART_DIRECTIVES } from 'angular2-highcharts';

@Component({
    selector: 'simple-chart-example',
    directives: [CHART_DIRECTIVES],
    template: `
        <chart [options]="options"></chart>
    `
})
export class SimpleChartExample {
    constructor() {
        this.options = {
            title : { text : 'simple chart' },
            series: [{
                data: [29.9, 71.5, 106.4, 129.2],
            }]
        };
    }
    options: Object;
}

I have added all the dependencies in my project. But while running I am getting error

Severity Code Description Project File Line Suppression State Error TS2307 Build: Cannot find module '@angular/core'.

The error is getting from angular2-highcharts files.

I don't want to use angular (1.x) version in my projects. I only want to use angular beta version. Can anyone help to solve the issue.


Solution

  • you are using beta angular2 distro. Since it has gone RC it uses @angular/..

    So update your angular2 and it will work.

    "dependencies": { "@angular/common": "2.0.0-rc.1", "@angular/compiler": "2.0.0-rc.1", "@angular/core": "2.0.0-rc.1", "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", "@angular/router": "2.0.0-rc.1", "@angular/router-deprecated": "2.0.0-rc.1", "@angular/upgrade": "2.0.0-rc.1", }