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
Webpack Error: Cannot find module "./locale" after updating to 2.19.0 #4216
Comments
I have the same, confirming this error. |
same here |
Can confirm:
|
Same problem here. Would downgrading fix the problem? |
Same here, broke multiple apps that I work on. |
@patricksteenks : yes. Fix like this in you package.json |
@ichernev hey, but I'm using locale without importing. Just using |
Same issue on Angular-CLI built project |
Confirmed. |
VueJS 2 Webpack builds impacted too. Temp fix is as GautierT suggested (downgrade momentjs) package.json (issue with moment-timezone dep on moment 2.19) "moment": "2.18.1",
"moment-timezone": "^0.5.13", package.json (issue in general) "moment": "2.18.1" |
I can confirm this is also happening! |
i can confirm.
@renedx just this line enough |
Same in an Angular 4 application. |
Got hit by this as well. I suspect it is webpack doing some magic to recognize the dynamic "require", and can no longer recognize it under the new name, and thus the locales never get bundled into the package. (Incidentally, this whole situation sounds an awful lot like exactly what ES6 dynamic imports are for. We can dream :-) |
I use in webpack from this page new IgnorePlugin(/^\.\/locale$/, /moment$/) Now remove it And in require const moment = require('moment'); Now const moment = require('moment').default; |
Strictly speaking, I think the Angular connection is simply because most Angular projects use Angular-CLI, which internally uses Webpack. But it may be related to some specific Webpack configuration in that stack. |
Repent, repent, doomsday is here! |
Same here.
|
Same here - I fixed it with a feature of yarn to overload the default settings of a package: place this in your main package.json (adapt "moment-timezone" to the name of the package which does load moment if you do not directly load moment):
|
just like an 10km asteroid .... same here ... |
What is the ETA for fix? |
Okay, here's where we're at:
|
I'm using version "2.25.1" and still happening! |
@m4mariaoni - that's because u installed without If you're still encountering this issue after locking moment to 2.24.0, nuke the moment folder from node_modules and reinstall your packages with |
Thanks, @jolalla, I first tried downgrading the version but it didn't work for me. Finally adding the resolutions block showed some magic :) For others who are are facing a similar issue with their react app. They can do the following 2 steps to resolve it. In dependencies, replace And add the resolutions block in package.json "resolutions": { Works for me too! Thank you!! :D!thinks! |
Replacing
with
works for me! The usual, |
In spite of doing all above measures, still not working... This is frustrating |
Previously created repositories were used moment 2.24.0 with React, and it's still working, but install moment2.24.0 now, doesn't working.... (I've tried all above measures, too) What is the cause? |
I'd imagine you may have a ^2.24.0 instead of 2.24.0 somewhere in a package.json @wlsdud2194? |
I don´t, and still the error keeps coming. It´s weird |
moment version is I followed this process, one of the above measures
works for me, but don't know why working...😂 Thank you for your interest : ) @agrohs |
Had to downgrade from |
Try running |
And add the resolutions block in package.json
"resolutions": { "moment": "2.24.0" }
remove node_modules directory and reinstall package from yarn.
rm -rf package-lock.json && node_modules
联系人:刘先生
联系电话:18908205973
传真:028-86676917
E-mail:office@szdma.com
公司名称:成都首志科技有限公司
公司网址:www.szdma.com
地址:成都市滨江东路162号银海大厦
…--------------------------------------------------------------
成都首志科技有限公司成立于2010年,是成都一家面向中小企业的专业软件定制开发公司,公司主要服务对象是中小企业,提供局域网搭建、网站建设、软件定制解决方案等,并提供从手工业务到电脑业务一整套服务。公司以“诚信为本,服务至上”的原则,突现公司形象;通过我们不懈努力,为客户提供优质服务。
|
We are getting In dependencies Any help would be greatly appreciated. |
The latest patch 2.25.3 seems to have fixed it, update the momentjs version to: |
For those who've lost some confidence in moment, and don't want their apps to completely break from this issue happening again in the future - I switched a medium-sized codebase over to luxon without too much trouble. |
Thank you people... I changed version to 24.0 and added the "resolutions": { "moment": "2.24.0" } and ran npm install Then it seemed to work again (working with React, by the way). Cheers! |
Thank you @jasontll , it works for me |
None of these solutions worked for me today. |
its also worked for guys thanks a lot :-) |
I run also in this trouble. I've fixed it with the latest version as of |
With 2.29.1 dynamic import of locales still does not work with webpack and the create-react-app config (worked with 2.24). A workaround is to add a new Javascript file in your project that just imports the one locale and then dynamically import that file. |
I added a metro.config.js file after upgrading, which didn't allow the files to be loaded correctly. Removed the file and it works again. |
Ref: moment/moment#4216 (comment) Signed-off-by: Rajesh Rajendran <rjshrjndrn@gmail.com>
Ref: moment/moment#4216 (comment) Signed-off-by: Rajesh Rajendran <rjshrjndrn@gmail.com>
i was changed aliasesRequire in require('./locale/' + name);
// because defineLocale currently also sets the global locale, we
// want to undo that for lazy loaded locales to require('moment/locale/' + name);
// because defineLocale currently also sets the global locale, we
// want to undo that for lazy loaded locales and now works without error |
It worked perfect for me, thank you so much. Keep in mind guys that if you are using workspaces, you should remove de package-lock.json and node_modules from every directory that could use the library. |
Edit: If you set your dependency to 2.18.1, everything will be fine. We are coordinating with some other libraries to find a permanent solution
Edit 2 : Set
"moment": "2.18.1"
in your package.jsonEdit 3: We believe this is fixed.
Hello.
Using create-react-app. After updating moment to 2.19.0 i have this error on load :
Error: Cannot find module "./locale"
-> 9 stack frames were collapsed.
./src/utils/Utils.js
src/utils/Utils.js:1
The text was updated successfully, but these errors were encountered: