grofit / aurelia-chart

A chart element for aurelia which is powered by chart js using html5 canvas.
MIT License
46 stars 25 forks source link

error TS2307: Cannot find module 'chart.js'. #25

Open kentnguyen opened 7 years ago

kentnguyen commented 7 years ago

I'm using Aurelia CLI (0.22.0) and install aurelia-chart & chart.js via npm, as well as edit package.json according to README but it failed to build when adding the import line to main.ts

[16:53:03] gulp-notify: [Error running Gulp] Error: src/main.ts(3,19): error TS2307: Cannot find module 'chart.js'.
[16:53:03] TypeScript: 1 semantic error
[16:53:03] TypeScript: emit succeeded (with errors)

Without the import line, the build was fine but the page doesn't load with when serving via au run --watch when adding .plugin('aurelia-chart') to main.ts

Any idea what I should do? Should I make any changes to aurelia.json file?

hozn commented 7 years ago

I'm getting a little farther with this config in aurelia.json

{
            "name": "chart.js",
            "path": "../node_modules/chart.js/dist",
            "main": "Chart.min"
          },
          {
            "name": "aurelia-chart",
            "path": "../node_modules/aurelia-chart/dist/amd",
            "main": "index",
            "resources": [
              "elements/chart-element.js",
              "elements/chart-element.html",
              "attributes/chart-attribute.js"
            ]
          },

(You also have to add chart.js, if you did not.)

npm install --save chart.js

I have no errors now -- but cannot get a chart to actually display. Not sure what's going on yet.

jbnv commented 7 years ago

@hozn, check your developer panel. I added your code into my project (I'm #26). Now it compiles and runs on the command line, but is throwing an error message on the JavaScript side.

hozn commented 7 years ago

@jbnv, thanks -- yeah, I'm not getting errors but chart isn't drawing. Puzzled about the issue, so I opened #27 .

grofit commented 7 years ago

sounds odd, I mean you can always just thrown random console.logs or debugger statements into the module code (in jspm/node_modules etc) to check the methods are being run correctly as the example on the site works and is the baseline for if things are working and that still seems fine, so I am not saying there isnt an error rendering but given the whole "loading the module" problems I would not be too surprised if it is related to that and not the internal rendering code.