GithubHelp home page GithubHelp logo

Error: If you specify a timezoneId, make sure that you've added a moment-timezone package to your app about meteor-autoform-bs-datetimepicker HOT 11 CLOSED

hsribei avatar hsribei commented on May 30, 2024
Error: If you specify a timezoneId, make sure that you've added a moment-timezone package to your app

from meteor-autoform-bs-datetimepicker.

Comments (11)

hsribei avatar hsribei commented on May 30, 2024

It seems like this is the culprit:

if (typeof moment.tz !== "function") {
  throw new Error("If you specify a timezoneId, make sure that you've added a moment-timezone package to your app");
}

The condition is evaluating to true and throwing up that error, but on the console, I get this:

> typeof moment.tz
"function"

So it must be a loading order issue, but I'm a little out of my depth on that. Appreciate any pointers.

from meteor-autoform-bs-datetimepicker.

aldeed avatar aldeed commented on May 30, 2024

I'm not sure other than agreeing it's probably due to loading order. Typically I would expect all packages to be loaded before anything would be setting autoform input values.

You might try editing your packages file and moving mrt:moment-timezone to somewhere near the top.

I think I didn't list any moment-timezone dependencies because you could add it in a lot of ways, but we could add a weak dependency if this becomes a problem. I was kind of waiting to see if there would eventually be an official package, as there now is for moment.

from meteor-autoform-bs-datetimepicker.

hsribei avatar hsribei commented on May 30, 2024

Tried putting it at the very top of packages, same thing though. I'm thinking it could also be some sort of scope issue.

I'll try adding mrt:moment-timezone as a dependency in a local fork of meteor-autoform-bs-datetimepicker and see if that helps.

from meteor-autoform-bs-datetimepicker.

sheldonkotyk avatar sheldonkotyk commented on May 30, 2024

I'm getting this same error but only on my update form, insert form is fine.

from meteor-autoform-bs-datetimepicker.

sheldonkotyk avatar sheldonkotyk commented on May 30, 2024

OK, if I have the schema set with type: string and a timezoneId, the fields show up in my update form but I get this warning in the console and the data is not displayed.

"Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to moment/moment#1407 for more info."

If the schema is set with type: date and a timezoneId, the fields do not show up and I get:

Error: Exception in template helper:
Error: If you specify a timezoneId, make sure that you've added a moment-timezone package to your app
at Object.dateToNormalizedLocalDateAndTimeString (utility.js:411)
at Object.AutoForm.addInputType.valueIn (autoform-bs-datetimepicker.js:12)
at getInputValue (autoform-inputs.js:205)
at Object.afFieldInputContext (afFieldInput.js:67)
at bindDataContext (lookup.js:26)
at Blaze._wrapCatchingExceptions (exceptions.js:51)
at Spacebars.call (spacebars-runtime.js:130)
at Spacebars.mustacheImpl (spacebars-runtime.js:67)
at Object.Spacebars.dataMustache (spacebars-runtime.js:99)
at afFieldInput.html:9

in the console.

from meteor-autoform-bs-datetimepicker.

sheldonkotyk avatar sheldonkotyk commented on May 30, 2024

OK, tracked it down to multiple moment packages being installed.

from meteor-autoform-bs-datetimepicker.

came avatar came commented on May 30, 2024

I also get this error as sheldonkotyk at the same location.
Besides mrt:moment and mrt:moment-timezone I had the momentjs:moment package included.
However, removing this has not solved the issue. @sheldonkotyk how did you resolve this issue?

BR, Carsten

from meteor-autoform-bs-datetimepicker.

gekosurf avatar gekosurf commented on May 30, 2024

Same here.

Interestingly @ http://localhost:3000/packages/aldeed_autoform-bs-datetimepicker.js
Line 75
if (typeof moment.tz !== "function") {
IS OK

whereas:

http://localhost:3000/packages/aldeed_autoform.js

The next function called, FAILS:
AutoForm.addInputType("bootstrap-datetimepicker",
Line 474 if (typeof m.tz !== "function") {

from meteor-autoform-bs-datetimepicker.

aldeed avatar aldeed commented on May 30, 2024

@came, @gekosurf, @obvio171 I think this should be fixed in v1.0.6. I added weak dependencies on the moment packages. Can someone confirm?

from meteor-autoform-bs-datetimepicker.

joeligy avatar joeligy commented on May 30, 2024

I'm still running into this issue in the newest version. The only moment packages that I have installed are:
mrt:moment
mrt:moment-timezone.

Getting the same error mentioned at the top of the thread.

from meteor-autoform-bs-datetimepicker.

aldeed avatar aldeed commented on May 30, 2024

I published an updated version of mrt:moment-timezone as aldeed:moment-timezone. If you switch to aldeed:moment-timezone, these load order issues should be resolved.

from meteor-autoform-bs-datetimepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.