Hi i started a project with angular 7 and installed chart.js and ng2-chart as in the github readme.
npm install ng2-charts --save
and
npm install chart.js --save
then in my app.module i did:
import { ChartsModule } from 'ng2-charts';
imports: [
...
ChartsModule
],
But i cannot even compile the project, i get, when i do a ng serve i get:
ERROR in node_modules/ng2-charts/lib/base-chart.directive.d.ts(11,32): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(12,31): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(13,34): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(14,33): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(15,34): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(16,33): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(17,42): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(18,41): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(19,41): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(20,40): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(21,34): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(22,33): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(23,32): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(24,31): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(25,40): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(26,39): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(27,39): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(28,38): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(29,39): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(30,38): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(31,33): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(32,32): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(33,28): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(33,49): error TS2503: Cannot find namespace 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(34,29): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(36,38): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(57,12): error TS2304: Cannot find name 'Chart'.
node_modules/ng2-charts/lib/base-chart.directive.d.ts(67,35): error TS2304: Cannot find name 'Chart'.
Same problem here.
It seems that I have missed a dependency for @types/chart.js
As a workaround in the mean time you can do:
npm i -D @types/chart.js
It will solve the issue
That did not solve my problem...
Most helpful comment
It seems that I have missed a dependency for
@types/chart.jsAs a workaround in the mean time you can do:
npm i -D @types/chart.jsIt will solve the issue