-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not log error when requiring moment-timezone multiple times in Node #231
Comments
Except that it can actually cause errors when the same time zone is defined more than once. @timrwood - Perhaps we need to do more than just log an error in order to accommodate node.js scenarios? |
AFAIK node has a caching mechanism when requiring modules so that it shouldn't load module more than once |
If that's the case, then why would you be seeing the error message in your logs? It should only appear then if it wasn't already loaded in the cache, right? |
Perhaps you could supply a GIST with a minimal example that gives the error? |
I can't seem to be able to reproduce this. I have a setup where I require moment-tz couple of times in my app and I also require a second module that requires moment-tz. When I try to replicate it I don't get the error message. It looks like some quirk in npm that i'm not aware of, I will try to investigate it further and understand why it's being loaded twice in my app |
@mj1856 problem solved. I had couple of old dependencies in my node_modules folder. After cleaning it up and restarting the module seems to be loading only once. Sorry for the noise, Thanks for your help ! |
No problem, and glad to hear you got it working! 😄 |
We're still having this problem. We use moment-timezone inside of our app, but the ORM sequelize also uses moment-timezone internally. So we get this error. What exact problems come from two different apps requiring moment? Can that problem still occur when a moment-timezone is loaded inside both the application and a dependency? |
@timrwood - Is there a better way to handle this? Loading into two different instances should be ok. It's only loading twice in the same instance that is problematic. Maybe just make the loading idempotent instead of throwing an error? |
I seem to be running into the same issue as @FredKSchott. Any discussion regarding two different apps requiring moment?
|
Same here, any suggestions? |
+1 Making the loading idempotent as suggested by @mj1856 would be ideal imo. |
I went from 0.3.1 to 0.5.0. I'm requiring How do I solve this? |
I'm getting this as well. Sequelize has moment-timezone as a dependency and almost certainly that causes the issue. |
+1
|
Same issue here, let’s say I have an app using |
I'm able to reproduct this problem if i install the package rschmukler/agenda, because it depends on [email protected] and [email protected] -> which in turn depends on [email protected]. |
+1 |
Hi I'm also getting "Moment Timezone 0.3.1 was already loaded with data from 2015a" when I require('agenda') from rschmukler/agenda. |
I've started work on #298, breaking moment-timezone into smaller es6 modules, which should make this problem easier to address. The main problem is that the data loaded in an older version does not match the data loaded in a newer version. I suppose we could compare the |
Also getting this... |
still not fixed? |
It’s been almost a year, maybe we could remove the |
+1 |
Another month |
This is a pretty big pain for me, as the logging library used on an e-commerce project I am tasked with fixing suffers from this issue, so none of the logs have dates or times. It is insanely difficult for me to track down which logs occurred when to match logs to observed behavior in the system at the time they were observed. At this time, I am reduced to sitting and waiting for the error to happen again to see exactly which logs are written, which means I am literally waiting for this company to lose more money. Can this be prioritized in any way? If you have not completed a fix, but have completed your reorganization, can it be placed in a branch so that the community (myself included) can try to complete the fix ourselves without stepping on your work? I would also consider this a bug versus an enhancement; it prevents usage. |
Seriously, just remove the useless
|
This is polluting our logs, could you change from 'error' to 'warning' please? |
+1 |
5 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 !!!! |
+1 |
Hi. i saw why this error is log. To prevent the log error i only loaded And now the error is gone. Greetings. |
I think the problem is NPM 3's deduplication and
So when I'd have to think of some ways that could be done to solve this, but this isn't an easy fix. If the projects were merged, the problem would probably go away though... |
This is just horrible.
my app just had broken because of this. I installed new package |
The console.log has been removed and released 0.5.11 |
I just saw this from
|
now,it's
what should i do? load js: |
In Node it is quite common to require a module in multiple places
Right now if I require moment-timezone in multiple places I am getting
That comes from this line (#212 )
This shouldn't be logged as an error and just clutters the server logs.
If anything, it should be a warning but in Node env it shouldn't be printed at all IMO
The text was updated successfully, but these errors were encountered: