aurelia-chart icon indicating copy to clipboard operation
aurelia-chart copied to clipboard

Looking for files in all the wrong places

Open jbnv opened this issue 8 years ago • 9 comments

Getting this error as I attempt to start up my application from the CLI:

Tracing aurelia-chart...
{ uid: 10,
  name: 'writeBundles',
  branch: false,
  error:
   { [Error: ENOENT: no such file or directory, open '/Users/mac/Projects/SongChartAurelia2/src/observers/model-observer.js']
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/Users/mac/Projects/SongChartAurelia2/src/observers/model-observer.js',
     moduleTree: [ 'aurelia-chart' ],
     fileName: '/Users/mac/Projects/SongChartAurelia2/node_modules/aurelia-chart/dist/commonjs/index.js' },
  duration: [ 217, 485490417 ],
  time: 1481168967221 }

Aurelia is trying to find observers/model-observer.js in the application's root src directory, not the one for aurelia-chart. I added both aurelia-chart and chart.js through NPM. How can I resolve this problem?

jbnv avatar Dec 08 '16 03:12 jbnv

It could be related to #21 #25, it seems depending on how you are consuming it there could be problems, the "core" logic in this plugin is sound, and has been since inception, almost all issues that plague it are down to the tooling around consuming modules so I have said in previous issues I don't have the capacity currently to fix it as the package.json main is hooked up to the right file so it should just work.

Hopefully someone can do a PR who knows the current tooling and approaches for Aurelia and then everyone can be happy until the next tooling change occurs :(

One other thing to mention is that you should load these plugins up as a plugin not a feature which some people use as a hack around, you may also need to consult the CLI docs to see if you need to add any custom properties to your package.json to imply what should be bundled.

grofit avatar Dec 08 '16 08:12 grofit

I'm at my day job right now and the project is a personal project, so I can't look into it further at the moment but will do so later. I am pretty sure that I am loading it as a plugin, but I will double-check.

jbnv avatar Dec 08 '16 15:12 jbnv

I set my aurelia.json per hozn's post in #25. Now my code compiles and runs at the command line, but throws undefined 'exports' on the first line of the code block below. Is this one of the variations of aurelia-chart?

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.configure = configure;

var _observersModelObserver = require("./observers/model-observer");

function configure(aurelia) {
    aurelia.globalResources("./elements/chart-element", "./attributes/chart-attribute");

    aurelia.container.registerTransient(_observersModelObserver.ModelObserver);
}

jbnv avatar Dec 09 '16 03:12 jbnv

Changed the code in aurelia.json to this:

          {
            "name": "chart.js",
            "path": "../node_modules/chart.js/dist",
            "main": "Chart.min"
          },
          {
            "name": "aurelia-chart",
            "path": "../node_modules/aurelia-chart/dist/amd",
            "main": "index"
          },

Now I'm getting the h.load error when I include .plugin('aurelia-chart').

jbnv avatar Dec 10 '16 03:12 jbnv

Do they still have a plugins skeleton app? as it may be worth someone just grabbing that, putting these files in there and building off that, as so far 99% of the problems I receive are just trying to load the plugin in, there is rarely a problem once the plugin has been successfully loaded.

grofit avatar Dec 10 '16 08:12 grofit

Yes. You can generate one with the new Aurelia CLI.

jbnv avatar Dec 10 '16 14:12 jbnv

I created a shell application with the modifications and uploaded it to GitHub. The first commit is the unmodified shell application; the second commit are the changes that trigger the bug.

jbnv avatar Dec 10 '16 15:12 jbnv

is it the package.json changes or the aurelia.json changes which primarily cause it? or is it just when both are there?

grofit avatar Dec 12 '16 10:12 grofit

With this aurelia.json config

          {
            "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"
            ]
          },

The aurelia-cli can run the app, but the console outputs two errors: Uncaught Error: Mismatched anonymous define() module: function (exports, _aureliaFramework, _observersModelObserver, _chartJs)

Each one is caused respectively by elements/chart-element.js and attributes/chart-attribute.js (aka if i dont load these resources, i don't get the error but i can't use the package...)

This is highly related to jbnv's comment

obust avatar Dec 23 '16 13:12 obust