[Packager] Requiring momentjs locale fails
See original GitHub issueI’m trying to use a different locale for Moment.js, and I keep receiving the same error. This is the code:
var moment = moment();
moment.locale('es');
And I’m receiving this error in the Chrome Dev Tools console:
Error: Requiring unknown module "./locale/es". If you are sure the module is there, try restarting the packager.
stack:
Object.ErrorUtils.applyWithGuard index.ios.bundle:880
require index.ios.bundle:195
loadLocale index.ios.bundle:42796
chooseLocale index.ios.bundle:42774
locale_locales__getLocale index.ios.bundle:42867
Moment.locale index.ios.bundle:44506
eval eval at evaluate …:1
URL: undefined
line: undefined
It doesn’t seems a Moment.js error though.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
How to prevent moment.js from loading locales with webpack?
I'm looking at the source and it seems that if hasModule is defined, which it is for webpack, then it always tries to...
Read more >Moment.js documentation - DevDocs
Moment.js 2.29.4 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
Read more >Moment.js | Home
Download · Install · Format Dates · Relative Time · Calendar Time · Multiple Locale Support.
Read more >moment | Yarn - Package Manager
A JavaScript date library for parsing, validating, manipulating, and formatting dates. Project Status. Moment.js is a legacy project, now in maintenance mode.
Read more >Module not found: Can't resolve 'moment' error | bobbyhadz
To solve the error "Module not found: Error: Can't resolve 'moment'", make sure to install the moment package by opening your terminal in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@alvaromb - just a quick thought from browsing the moment docs, what about:
@brentvatne loading the locale directly i.e
require('moment/locale/es');
works. I’m trying to set the locale dynamically, AKA, I get the locale from user device and then load the specific locale.Is there other way to solve it besides: