![]() I have yet to get the “moment is not a function” issue resolved. meteor create modular-app cd modular-app mkdir nodemodules npm install moment echo 'import moment from 'moment' ' > modular-app.js echo 'console.log(moment().calendar()) ' > modular-app.js meteor When you run this app, the moment library will be imported on both the client and the server, and both consoles will log output similar to: Today. 5 months, 3 weeks, 6 months since x) without having to account for varying month sizes (and leap years, etc.) myself. ![]() Finally I tried downloading the twix.js file and placing it in different directories, but nothing has worked. I wished to use it to do necessary date\time calculations (i.e. I used npm to install twix package, but neither meteor no mrt will add twix, responding Package named twix doesn't exist in your meteor installation which I guess makes sense, it being a Nodejs package not a Meteor package. Yes, though technically I was just trying to see if I imported it correctly. In your specific example, your newMoment would actually be set to the current date and time (it’s equivalent to var newMoment = new Date() - is that what you expected? Just import moment in your file and invoke moment ().format ('MMM') it will show the current date time with the format. js file on the Client (Under the Client folder), I have no need of it server side as it’s not privileged information in any way. To get month name in moment js, use the moment ().format () method by passing desire month format string parameters. Error message remains the : did you import in a client (or shared) file? If you imported only on the server, then moment won’t be available in your client. Meteor: How to add and query Dates in Mongodb with Momentjs. The problem is that nowMin30mins is only computed once when the publication is activated, and won't update afterwards, even though you have an observeChanges on Events.You basically have two constant values (nowMin30mins and endOfToday) bracketing the documents that will be shown and only adding or removing items will cause them to disappear. For the relevant bug fix information, you can Git Commit 2e43a9 and ae8395 or Meteor Issue 4010 or 4109. ![]() This problem was a bug in the way that Meteor was reloading itself in the shell environment and is fixed in Meteor 1.2. moment-timezone0.5.23 moment2.22.2 and meteor npm install gives: audited 107 packages in 1.913s found 0 vulnerabilities In the file where I'm using moment-timezone I have. Replacing, the import with the NPM style require didn’t solve it. moment.js and meteor, problems using stored moments. Even after restarting the app it still doesn't work. Var startDate = moment().startOf(‘month’) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |