hey folks i'm using the Angular2 CLI and trying to import the chart.js module but every time i run up the server I get a 'cannot find module "chart.js"'

import { Component } from '@angular/core';
import Chart from 'chart.js';

@Component({
 selector: 'app-root',
 templateUrl: './app.component.html'
 })

 export class AppComponent {
   title = 'Test';
   let myChart = new Chart({});
};
share|improve this question
    
Try: import 'chart.js/dist/Chart.min.js'; Assuming you did an npm install of chartjs already. – cmonkey yesterday
    
i did npm install it but didn't fix it. I need to import Chart from it's directory – Fernando B yesterday

You may want to try ng2-charts or another Angular2 chart.js library to set this up. It makes it a lot easier to import and use. From the README...

import { ChartsModule } from 'ng2-charts/ng2-charts';

// In your App's module:
imports: [
   ChartsModule
]
share|improve this answer
    
That's what i'm using but when I try to create a new chart i keep getting a "cannot find name 'Chart' " – Fernando B 7 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.