Ng2-charts.js does not export ChartsModule

I’m struggling to get the charts to work again after the RC0 update. I’m struggling to debug because I believe I’m lacking some ionic ng2 experience.

How to I diagnose this problem? I’ve run the following commands:
npm install ng2-charts --save
npm install chart.js --save

Then I linked the following javascript in index.html

I used cloudflare because I noticed that other documentations pointed directly to node_modules, but when I build node_modules for ng2-charts doesn’t get served.

In this situation, what does it mean that the “js does not export ChartsModule”? When I look at the charts.js script I see the following line:
exports.ChartsModule = ChartsModule;
Any guidance is greatly appreciated.

Is this a situation where I need to modify the rollup.config.js and why?

For those interested… It seems as if I’m making progress by modifying the rollup.config.js.

plugins: [
ngTemplate(),
commonjs({
namedExports: {
‘node_modules/ng2-charts/ng2-charts.js’: [‘ChartsModule’]
}
}),
nodeResolve({
module: true,
jsnext: true,
main: true,
browser: true,
extensions: [’.js’]
})
]

After adding a named export I can now see my node_modules getting included in the build.

So now the following export is no longer erroring:
import {ChartsModule} from “ng2-charts”;

imports: [
IonicModule.forRoot(MyApp),
ChartsModule
],

@keeper3000 I have a similar issue with ng2-cordova-oauth, I tried modifying node_modules/@ionic/app-scripts/rollup.config.js and added

        'node_modules/firebase/firebase.js': ['initializeApp', 'auth', 'database']
        'node_modules/ng2-cordova-oauth/core.js': ['CordovaOauth']

but i still get the same error:

/ng2-cordova-oauth/core.js does not export CordovaOauth

Did you do something else as well ?

Nope I just added that 1 line into the rollup.

Although, I’m still working through this. I tried to add a 2nd module and am getting the error with the 2nd one.

Maybe you grabbed the wrong js file? The one I’m pointing to has a file with very few lines of content:
“use strict”;
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty§) exports[p] = m[p];
}
__export(require(’./components/charts/charts’));

Ok I finally got the ng2-charts working with RC0.

In addition to the change I made to my rollup.config.js above, I had to put Chart.bundle.js in src/assets/scripts

Then I included this at the bottom of my head block in index.html:

for anybody still having trouble, i posted another solution here:

After updating my ionic app with RC0 and ng2-charts with latest(1.3.0) i am also getting same error.

ng2-charts.js does not export ChartsModule.

Any help?
Thanks in advance.:smile:

Thanks that works!
But I have a little concern about the next Ionic RC, we are going to update our dependencies and it will override rollup.config.js. So, how can we override this rollup.config.js with our own in the root directory or is there any other better way to import modules?

is there any specific reason why you would want to ng2-charts.js?

if not just use the charts.js library the way i am doing. You can even use the combined charts that way!

Good news folks.

My issue on GitHub was just closed and aot support has been added!