Cannot read property 'tz' of undefined - Ember Moment Timezone
13,879
You need to import Moment before importing Moment Timezone.
See http://momentjs.com/timezone/docs/
Author by
Coherent
Updated on June 09, 2022Comments
-
Coherent almost 2 years
I have an ember app that I am trying to add moment with time zone into:
{ "name": "front-end", "dependencies": { "handlebars": "~1.3.0", "jquery": "^1.11.1", "ember": "1.8.1", "ember-data": "~1.0.0-beta.14.1", "ember-resolver": "~0.1.7", "loader.js": "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.17.1", "bootstrap": "~3.3.2", "ember-simple-auth": "0.7.3", "jquery-autosize": "~1.18.12", "moment-timezone": "~0.3.0" } }
I load the js file with this line in my Brocfile.js:
app.import('bower_components/moment-timezone/builds/moment-timezone-with-data-2010-2020.min.js');
When I start the ember server I get the following error even before I call moment in any of my custom scripts:
Uncaught TypeError: Cannot read property 'tz' of undefined
Could anyone tell me the proper way to load moment-timezone? Thanks!