0

In a new ember 3.28 addon project:

npm install chart.js --save
ember g component-class chart

Insert <Chart /> into application.hbs on dummy app and in addons/component/chart.js, add this

import Chart from 'chart.js/auto';

Running app gives:

Uncaught Error: Could not find module `chart.js/auto` imported from `chartjs-test/components/chart`

Yet if the import Chart goes into the application.js route in the dummy app instead, it works. How can you import this module correctly from within an addon component?

Update: Same issue with other installed packages eg. import chroma from "chroma";

user1814277
  • 304
  • 2
  • 9

1 Answers1

2

Turns out you need to add the same import statement into app/component/chart.js:

UPDATE: The above isn't the proper way and causes issues when using the addon elsewhere. The real solution is to move ember-auto-import to dependencies from devDependencies in package.json of the addon

user1814277
  • 304
  • 2
  • 9