Hello there,
I am currently working on an Angular project where I want to incorporate a chart plugin. To achieve this, I executed the following commands:
npm install angular2-chartjs
npm install chartjs-plugin-labels
Following that, I imported it into my TypeScript file in the following manner:
import { ChartModule } from 'angular2-chartjs';
import 'chartjs-plugin-labels';
In my package.json file, you can find these dependencies:
"angular2-chartjs": "^0.5.1",
"chartjs-plugin-labels": "^1.1.0",
When running my Angular project locally using the ng serve
command, everything works perfectly fine.
However, after generating the web package and deploying it to the SIT Apache web server, I encounter the "Can not find Chart object" error upon loading the page.
The error message displayed in the Chrome console is somewhat similar to the following: https://i.sstatic.net/ojWT0.png
This issue seems to be originating from the chartjs-plugin-labels.js file:
https://i.sstatic.net/zunaR.png
To generate the SIT package, I use the npm run sit
command:
The excerpt below shows part of my package.json
explaining what happens during ng serve
and npm run sit
:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"demo": "ng build -c=demo --base-href=/demo/",
"dev": "ng build -c=dev --base-href=/sib/",
"sit": "ng build -c=sit --base-href=/sib/ && ts-node git.version.ts -c sit && ts-node app.version.ts -c sit",
"uat": "ng build -c=uat --base-href=/sib/ && ts-node git.version.ts -c uat && ts-node app.version.ts -c uat",
"prod": "ng build -c=prod --base-href=/sib/ && ts-node git.version.ts -c prod && ts-node app.version.ts -c prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"version": "ts-node git.version.ts -c prod"
},
My suspicion is that when executing the npm run sit
command, the process of generating the web package differs, leading to the Chart object not being included in the package for some reason.
Interestingly, no other plugins seem to have encountered such issues.
I would appreciate any guidance regarding this matter.