2
votes

I am using version 0.0.46 of Ember CLI.

In my bower.json file I have defined

{
  "name": "my-app",
  "dependencies": {
    "handlebars": "~1.3.0",
    "jquery": "^1.11.1",
    "ember": "1.7.0",
    "ember-data": "1.0.0-beta.10",
    "ember-resolver": "~0.1.7",
    "loader": "stefanpenner/loader.js#1.0.1",
    "ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3",
    "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
    "ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2",
    "ember-qunit": "0.1.8",
    "ember-qunit-notifications": "0.0.4",
    "qunit": "~1.15.0",
    "interact": "~1.0.26",
    "moment": "2.8.3"
  }
}

Did a bower install which loaded moment into bower_components. And in my Brocfile.js I have imported it.

app.import('bower_components/moment/moment.js');

module.exports = app.toTree();

And in my .jshintrc I have included it.

"predef": [{
  "document": true,
  "window": true,
  "-Promise": true,
  "moment": true
}]

And I created an application route just to see about getting it working.

import Ember from "ember";

var ApplicationRoute = Ember.Route.extend({
  currentDate: null,
  setupController: function(controller, model) {
    this._super(controller, model);
    this.set('currentDate', moment());
  }
});

export default ApplicationRoute;

It comes back saying moment is undefined. I have tried with momentjs and interactjs but neither want to work.

I tried adding

/* global moment */

to the application route. I also tried

/* global moment:true */

but still nothing.

Does anyone see what I'm doing wrong? Or is this a bug in version 0.0.46 of Ember CLI?

Thanks!

1
I just tested and it works fine for me. Only catch is that you have to kill the ember serve process and restart when editing the brocfile. have you tried that?tikotzky
Indeed I have. Several times. Tried creating new apps as well to see if I buggered some config. To no avail..bfcoder
I have a project on 0.0.46 that works fine with moment. Most likely some sort of local environment issue.Dhaulagiri
strange... I justed with a new app and it worked fine. If you open the devtools console and type moment do you get anything back?tikotzky
I was getting the same, then I found out that you need to restart and do "ember serve" again as the autoload doesn't account for newly imported bower components.David Douglas

1 Answers

2
votes

Well I went ahead and updated all the things (node and bower), created a new app and was able to get it to work. So it is something to do with some config that didn't update properly when I upgraded Ember CLI and did an ember init. I'll dig in and see what config isn't happy.

Found the problem. There were some old files sitting inside the public/assets folder (vendor.js vendor.css appname.js appname.css) that were causing unknown conflicts. Deleted those and bam, it works.