angular-timer icon indicating copy to clipboard operation
angular-timer copied to clipboard

humanizeDuration is not defined

Open jeffryang24 opened this issue 10 years ago • 21 comments
trafficstars

I use requirejs for loading my module. In requirejs, I add below code:

require.config({
          baseUrl: 'libs'.
          paths: {
                 'angular': 'path/to/angular',
                 'angular-timer': 'angular-timer/dist/angular-timer.min',
                 'humanize-duration': 'path/to/humanize',
                 'moment': 'path/to/moment'
          },
         shim: {
                'angular-timer': ['angular', 'moment', 'humanize-duration']
         }
});

But, the console always said that humanizeDuration is not defined, but moment is defined inside angular-timer.min.js

jeffryang24 avatar Sep 16 '15 10:09 jeffryang24

Solved!!!! I just add these code to the beginning line of angular-timer.min.js


var humanizeDuration = require("humanize-duration");   // same like my requirejs shim. Also from the humanizeDuration docs at https://github.com/EvanHahn/HumanizeDuration.js
var moment = require("moment");  // same like my requirejs shim


jeffryang24 avatar Sep 16 '15 13:09 jeffryang24

This did NOT work, and the fact that we have to add this to core code smells. This shouldn't be closed, it's still an issue.

shonatodc avatar Mar 04 '16 19:03 shonatodc

agreed.. been wanting to refactor/remove this dependency. But, haven't got a chance

siddii avatar Mar 04 '16 21:03 siddii

any update on this? Looks like these dependencies are still there and the lib doesnt work with the way its currently documented (just importing lib/angular-timer/dist/angular-timer.js )

santekotturi avatar Apr 17 '16 04:04 santekotturi

Any update on this. I am facing same error with all js file reference.

PradipShrestha avatar May 16 '16 12:05 PradipShrestha

The way I am currently able to work with webpack is to add plugin as: new webpack.ProvidePlugin({ 'moment': 'moment', 'humanizeDuration': 'humanize-duration' })

PradipShrestha avatar May 16 '16 13:05 PradipShrestha

This issue needs to be reopened.

jacqueslareau avatar May 17 '16 16:05 jacqueslareau

yup just faced this issue

LeoJavaAI avatar Sep 21 '16 14:09 LeoJavaAI

not sure how i should fix as i do not use require or webpack

LeoJavaAI avatar Sep 21 '16 14:09 LeoJavaAI

Leo-G: In that case, won't adding dependencies js: moment and humanizeDuration before angular-timer fix the issue?

PradipShrestha avatar Sep 21 '16 14:09 PradipShrestha

I was hoping I did not have to install and load more dependencies in my app, but if thats the best solution then will do it

LeoJavaAI avatar Sep 21 '16 14:09 LeoJavaAI

I'm just writing my own timer, I can't stand any unnecessary dependencies.

mattisx avatar Oct 02 '16 20:10 mattisx

+1 same issue.

My Solution: I added the .js files for moment and humanize-duration to my project directly from bower_components.

m477r33d avatar Oct 27 '16 18:10 m477r33d

having same issue why this issue is closed ?

ghost avatar Mar 07 '17 11:03 ghost

+1 same issue.

7medina avatar Apr 12 '17 19:04 7medina

Same issue here..

ghost avatar Apr 21 '17 10:04 ghost

Same issue

evankleist avatar Jul 18 '17 01:07 evankleist

same

johntiger1 avatar Oct 30 '17 17:10 johntiger1

I got it to work by adding humanize-duration.js and moment.js after angular-timer.min.js.
Its dependent on these other 2 libraries. Get the libraries from Github.

JMooreWeb avatar Nov 13 '17 18:11 JMooreWeb

i have the same issue "humanizeDuration is not defined" in including angular timer
how to solve that ?

jijeshkj avatar Jan 22 '18 11:01 jijeshkj

I'm getting same error humanizeDuration is not defined...???

kondalraodurgam avatar Oct 01 '19 06:10 kondalraodurgam