# Module ''chart.js'' has no exported member 'Chart'

**URL:** <https://forum.ionicframework.com/t/module-chart-js-has-no-exported-member-chart/57975>\
**Category:** ionic-v3\
**Created:** [July 19, 2016, 4:16pm UTC](https://forum.ionicframework.com/t/module-chart-js-has-no-exported-member-chart/57975 "2016-07-19T16:16:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ursi](https://avatars.discourse-cdn.com/v4/letter/u/fbc32d/32.png) [@ursi](https://forum.ionicframework.com/u/ursi)\
**Post date:** [July 19, 2016, 4:16pm UTC](https://forum.ionicframework.com/t/module-chart-js-has-no-exported-member-chart/57975/1 "2016-07-19T16:16:58Z")

</div>

I am porting my JS project over to TS and the Chart.js import is giving trouble. I did

`npm install chart.js --save`

And in my .ts file:

`import {Chart} from 'chart.js'`

For awhile i was stuck with `Cannot find module 'chart.js'` and the app would not start up. I somewhat followed Mike Hartington’s [external library guide](http://mhartington.io/post/ionic2-external-libraries/) (`--ambient` is deprecated?) and now have the error `Module ''chart.js'' has no exported member 'Chart'`

tsconfig  
 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/8/a/8a4805f4f06cdb4e24db9b88d3f79262f7accf47.png)

package.json  
 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/f/5/f5d22430a7d7203310950b06c1358c8ba08f0b5c.png)

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2016, 4:42pm UTC](https://forum.ionicframework.com/t/module-chart-js-has-no-exported-member-chart/57975/2 "2016-07-19T16:42:21Z")

</div>

Right, chartjs is not exporting a `Chart` class.

So what you can do is try this.

```auto
import * as chart from 'chart.js';

```

This will give you reference to the global chart API, which is what is being exporting.

---

<div class="post-metadata">

**Author:** ![ursi](https://avatars.discourse-cdn.com/v4/letter/u/fbc32d/32.png) [@ursi](https://forum.ionicframework.com/u/ursi)\
**Post date:** [July 19, 2016, 5:09pm UTC](https://forum.ionicframework.com/t/module-chart-js-has-no-exported-member-chart/57975/3 "2016-07-19T17:09:26Z")

</div>

Great, that fixed the error. But how can I now access a given class using this global API?

For example,

```
var plot = new Chart(ctx, {
    type: 'line',
    ...
    });

```

obviously has no idea what `Chart` is anymore, so I presumably have to access it from the import.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2016, 6:48pm UTC](https://forum.ionicframework.com/t/module-chart-js-has-no-exported-member-chart/57975/4 "2016-07-19T18:48:43Z")

</div>

you’d do

```javascript
// notice the lower chase chart
var plot = new char(ctx, {}

```

---

<div class="post-metadata">

**Author:** ![ursi](https://avatars.discourse-cdn.com/v4/letter/u/fbc32d/32.png) [@ursi](https://forum.ionicframework.com/u/ursi)\
**Post date:** [July 19, 2016, 6:51pm UTC](https://forum.ionicframework.com/t/module-chart-js-has-no-exported-member-chart/57975/5 "2016-07-19T18:51:39Z")

</div>

Just fixed it. That’s what I thought it would be, turns out the problem was with my canvas type.

```
let canvas: any = document.getElementById("chart");
let ctx = canvas.getContext("2d");
var plot = new chart(ctx, {
    type: 'line',
    ...
    });

```

Thanks very much!

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [July 19, 2016, 7:45pm UTC](https://forum.ionicframework.com/t/module-chart-js-has-no-exported-member-chart/57975/6 "2016-07-19T19:45:15Z")

</div>

Prefer `@ViewChild` to calling DOM methods on `document`.
