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
moment with locales: "./locale" not found #2979
Comments
See #1435. Workaround at the end. Thanks. |
the suggested workaround in "plugins" of webpack.config.js
did not work |
The problem mentioned above is about Unfortunately webpack tries to resolve all require statements - therefore this warning. |
@ichernev - I don't use webpack, but it seems like the point @mheimschild makes is reasonable. Not sure how to handle it though. |
The simplest solution how to convince webpack not to look for locales already included in the moment-with-locales.js is to force him to load something else instead. This worked for me: install empty module (it literary contains nothing) Hopefully this helps. |
Thank you for the workaround @mheimschild - It would have been nice to have had this resolved already in Webpack 2, even if the empty module would be included as a dev dependency automatically. |
It seems no need to use
|
just had similar problem when using momentjs via Meanwhile the locale files are located on will try webpack way mentioned above later EDIT: I was running this on windows, it looks like path problem. I tried running moment on linux and it works just fine |
I used the ignore module with good results. This might help someone: // /app/js/webpack.config.js
plugins: [
// Fixes warning in moment-with-locales.min.js
// Module not found: Error: Can't resolve './locale' in ...
new webpack.IgnorePlugin(/\.\/locale$/)
] |
@miguelrincon works fine! |
Awesome. It works! |
@miguelrincon or similar - can we get a pull request on docs for that? It would be in the use section under webpack. |
How To Fix in Hybrid Apps Ionic 3.5 with Angular 4 where we have no webpack.config file? |
I tried @miguelrincon suggestion above but it doesn't work. After looking around, I found this and it works perfectly! afc163/react-boilerplate@61ec8a1
|
It seems like there's a lot of useful advice in this thread. We'd love to take some PRs on our docs about this! https://github.com/moment/momentjs.com |
Thanks for all information. |
UPDATE: I found a solution. The right way to import :
and in ng-package.json:
By me was the structure false, the externals was not inside lib, so packgr was looking for lib.externals and couldn't find moment. Ng-packgr & moment I'm using the latest version, right now it's 2.22.2. While I'm trying to use ng-packagr and pack my project, I get this error. Same as : @vZanchiV 'locale' is not exported by 'node_modules\moment\src\moment.js' BUILD ERROR In project it's importer in this way : import * as moment from 'moment'; I found a workaround that didn't went well, I tried importing it like : import * as momentImported from 'moment'; const moment = momentImported; After this method I could export my project with ng-packagr but then I failed importing my project in another project, with this problem Module not found: Error: Can't resolve './locale' in 'C:\development\angularTest\angulartest\node_modules\modulename |
To confirm @francisrod01 's solution, I have changed my import, so that instead of
I changed to
And this solved for me. Hope it helps. |
I found the alias solution posted above by @M1chaelTran to work well. In case someone using Laravel Mix is wondering how to apply it, your
|
try all solution above, only the 'downgrade moment version' can resolve.But some of my module like 'antd' is require 2.19.0. so I think i can`t downgrade it |
This solution worked for me. |
@aaronkrohn thanks, this solution work with react-boilerplate v.4 |
Try to load locale first instead of moment.min.js. "moment": [ this will solve my issue. |
I have moment
Almost the same as fix of @aaronkrohn , but instead of |
Here is the fix for this issue: File: "moment\src\lib\locale\locales.js " line 56: Alexandra |
The fix is simple ... find any thing like this: import moment from 'moment/src/moment'; and replace it with this import * as moment from 'moment'; |
With create-react-app, below import worked fine for me
|
@mssui 's solution worked for me |
add above to package.json and re yarn. ok for me |
please where can I find this file, I can't find the path you referenced to, Thank in advance, I did a workaround by copying the moment source folder from an older project, and it worked for me |
Module not found: Can't resolve './locale' in '/usr/src/app/node_modules/moment/src/lib/locale' moment/moment#2979 (comment)
I'm getting this warning when using webpack:
any clues?
The text was updated successfully, but these errors were encountered: