ng2-charts: Error: Can't resolve '@valor-software/ng2-charts'
My angular app is running perfectly in local environment. But when I try to build app (ng build --aot), it shows the following error:
Module not found: Error: Can't resolve '@valor-software/ng2-charts' in '.\src\app'
ERROR in ./src/app/views/dashboard/dashboard.module.ngfactory.js
Module not found: Error: Can't resolve '@valor-software/ng2-charts' in '.\src\app\views\dashboard'
ERROR in ./src/app/views/dashboard/user-stats/user-stats.component.ngfactory.js
Module not found: Error: Can't resolve '@valor-software/ng2-charts' in '.\src\app\views\dashboard\user-stats'
Global Angular:
Angular CLI: 9.1.12
Node: 12.18.3
OS: win32 x64
Angular:
...
Ivy Workspace:
Package Version
------------------------------------------------------
@angular-devkit/architect 0.901.12
@angular-devkit/core 9.1.12
@angular-devkit/schematics 9.1.12
@schematics/angular 9.1.12
@schematics/update 0.901.12
rxjs 6.5.4
App angular::
"@angular-devkit/build-angular": "~0.900.1",
"@angular/cli": "^9.0.1",
"@angular/compiler-cli": "^9.0.0",
ng-charts
"ng2-charts": "^2.4.1",
"chart.js": "^2.9.2",
How can I solve this issue? Thanks in Advance
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 21 (13 by maintainers)
I think I just had a lucky break, I added this to
tsconfig.app.json, under"compilerOptions":So this is the complete file:
It now works with
ng2-charts@2.4.1Thanks for your tests and inputs. (You are pretty reactive 👍 )
I just manage to compile by making sure
package.jsondoesn’t contain"ng2-charts": "^2.3.3"but"ng2-charts": "2.3.3". The^was probably causing the 2.4.1 to be recognized as a compatible version.What worked for me:
"ng2-charts": "2.3.3"npm iin a terminal (at the root of your project)ng build --prod --build-optimizer --aotcommand.Hi @paviad thank you for your code snippet but I think your solution is only workaround. I found “@valor-software” string in v2.4.1 bundles and
metadata.json. It looks like package was build with incorrect package name. You should rebuild package, increment version and unpublish corrupted version 2.4.1grep "@valor-software" -R .I finally managed to reproduce it, with
@angular/cli@^8.0.0