4

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({});
};
Fernando B
  • 864
  • 2
  • 12
  • 27

1 Answers1

3

It looks like you may have incorrectly declared your Chart import

You have:

import Chart from 'chart.js';

But it should be:

import { Chart } from 'chart.js';

Also check that you have the chart.js npm package installed, if you don't have it properly installed, you can install it with:

npm install chart.js --save
Jarredvdv
  • 39
  • 2