moment.localeData is not a function

See original GitHub issue

Hi I use it in React 16.8.6.

.
.
.
import moment from 'moment-jalaali';
import fa from 'moment/src/locale/fa';
.
.
.
  useEffect(() => {
    moment.locale('fa', fa);
    moment.loadPersian();
  }, []);
.
.
.

It returns an error:

index.js?a67b:197 Uncaught TypeError: moment.localeData is not a function at eval (index.js?a67b:197) at Object…/node_modules/moment-jalaali/index.js (vendors~main.chunk.js:4637) at webpack_require (main.js:787) at fn (main.js:150) at eval (index.js:11) at Module…/app/containers/PayResult/index.js (main.js:1632) at webpack_require (main.js:787) at fn (main.js:150) at eval (index.js?b8af:1) at Module…/app/containers/App/index.js (main.js:1188)

and

[HMR] bundle has 1 warnings client.js?f33d:189 ./node_modules/moment/src/lib/locale/locales.jsModule not found: Error: Can’t resolve ‘./locale’ in ‘/Users/Erfan/WebstormProjects/myproject/node_modules/moment/src/lib/locale’

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
erfanatpcommented, Aug 26, 2019

@alitaheri Finally, I found the solution! I should change the order in internals/webpack/webpack.base.babel.js

From:

mainFields: [
  'browser',
  'jsnext:main',
  'main',
],

To

mainFields: [
  'browser',
  'main',
  'jsnext:main',
],
0reactions
Nefcantocommented, Jun 22, 2022

@reza3vi did not work for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: moment.locale is not a function #636
Hello, I have a react application served by nginx and im getting following error: twix.js:630 Uncaught TypeError: moment.locale is not a ...
Read more >
moment.localeData is not a function error message
I'm using moment library, I want to initial localeData function. but I got this error: Uncaught TypeError: moment.localeData is not a ...
Read more >
How to use the moment.localeData function in moment - Snyk
To help you get started, we've selected a few moment.localeData examples, based on popular ways it is used in public projects.
Read more >
LocaleData
LocaleData extends dayjs().localeData API to supply locale data. var localeData = require('dayjs/plugin/localeData') dayjs.extend(localeData) dayjs().
Read more >
Accessing locale specific functionality - momentjs.com
You can access the properties of the currently loaded locale through the moment.localeData(key) function. It returns the current locale or a locale with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found