11

I'm trying to use PrimeNG on my Angular project,Iv created a new project and tried to start, but it give me this error, I did the following steps:

  1. npm install primeng --save
  2. npm install @angular/animations --save
  3. npm install Chart.js --save
  4. npm uninstall ng2-charts

I added ../node_modules/chart.js/dist/Chart.js in my Angular.json

When I try to run my project with ng serve, it gives me this following error :

An unhandled exception occurred: Script file ../node_modules/chart.js does not exist

Any help can be usefull, thanks.

Edit:

Here is a part of my Angular.json :

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/YarbiTkhdem",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": ["src/favicon.ico", "src/assets"],
            "styles": ["src/styles.css"],
            "scripts": ["../node_modules/chart.js/dist/Chart.js"]
          },
YasuoHasaki
  • 157
  • 2
  • 3
  • 9

3 Answers3

21

You don't need the chartjs script in your angular json

"scripts": ["../node_modules/chart.js/dist/Chart.js"]

And you can add typing to charjs with :

npm install --save @types/chart.js

https://www.npmjs.com/package/@types/chart.js

  • 2
    Thanks a lot it worked, I was following a tutorial, they said that I should include that into my scripts, as u said I just removed `"../node_modules/chart.js/dist/Chart.js"` from Scripts on my `Angular.json` :) – YasuoHasaki Feb 25 '20 at 14:53
  • Great ,i’m glad to have helped :D –  Feb 25 '20 at 15:13
2

An unhandled exception occurred: Script file node_modules/chart.js/dist/Chart.min.js does not exist.

Just install using npm install chart.js --save

The problem will be fixed

0

If you have chart.js already install you need to make sure that the route is the right one. I don't know why but for me I had two leading dots... i had to remove one of the leading dots and it worked just fine.