Ng2-charts: error in angular 9

Created on 10 Feb 2020  路  9Comments  路  Source: valor-software/ng2-charts

npm WARN [email protected] requires a peer of @angular/common@^7.2.0 || ^8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@^7.2.0 || ^8.0.0 but none is installed. You must install peer dependencies yourself.

Most helpful comment

Same here:

warning " > [email protected]" has incorrect peer dependency "@angular/common@^7.2.0 || ^8.0.0".
warning " > [email protected]" has incorrect peer dependency "@angular/core@^7.2.0 || ^8.0.0".

Angular 9 support would be nice.

All 9 comments

Same here:

warning " > [email protected]" has incorrect peer dependency "@angular/common@^7.2.0 || ^8.0.0".
warning " > [email protected]" has incorrect peer dependency "@angular/core@^7.2.0 || ^8.0.0".

Angular 9 support would be nice.

These seem like only warnings. Do you encounter any errors that stop the charts from displaying?

No .. but it is interesting to correct the warnings

Yes ng serve --aot=true
image
Looks like it doesn't want to cooperate with chart.js 2.9.3

@speedy32 I had the same issue as you, however it turned out that the error is a result of the (now default) Ivy compiler, as it goes through your node_modules folder and adds the relevant parts it needs to the package root export, which allows it to be correctly handled by Ivy during build. You should be able to stop and start your serve instance, or explicitly run Ivy's ngcc command that is listed on the upgrade guide:
ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points

??????????/

@speedy32 I had the same issue as you, however it turned out that the error is a result of the (now default) Ivy compiler, as it goes through your node_modules folder and adds the relevant parts it needs to the package root export, which allows it to be correctly handled by Ivy during build. You should be able to stop and start your serve instance, or explicitly run Ivy's ngcc command that is listed on the upgrade guide:
ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points

I was wondering if this is something that needs to be executed in this library project, or in the project consuming the library. Can you elaborate?

I haven't published any plugins for Angular, so cannot say with absolute certainty, but as far as I understand it, it is something that has to be handled by the consuming project.

When building a project (either via ng serve or ng build), Ivy will automatically go through all the packages you're using and inject code at the bottom of the base export file that it relies on to correctly build the package into your build code (you can see this if you build, then go to the default export for the package, and inspect the bottom of it). You can tell if the build does it automatically as it outputs a message as it builds (something like "Generated ESM for [package name]".
However, there are scenarios where a package is not picked up by Ivy automatically (for example, if you install a package with NPM's deprecated add command). When this happens, you can either rebuild, or explicitly run the command that the builder runs (the command in my last comment).
It's not required, but if you want to be safe, the Angular team also recommend you put that command in the postinstall script in your package.json.

Whether there is a specific thing package developers can do to give better visibility to Ivy within their packages, I do not know, and the Ivy API docs would need to be consulted to find the answer. I manually ran ngcc when I encountered it, and I haven't had an issue with it since. This _may_ have also been a bug in Ivy I was not aware of however, as we have since upgraded our angular version a few times as Angular 9 releases have been happening, and none of my team have ever encountered the issue.

Closed by ff54527b

Was this page helpful?
0 / 5 - 0 ratings

Related issues

egervari picture egervari  路  4Comments

hggeorgiev picture hggeorgiev  路  4Comments

SteeledSlagle13 picture SteeledSlagle13  路  3Comments

raychenfj picture raychenfj  路  3Comments

tushartgsit picture tushartgsit  路  5Comments