Cannot resolve date-fns/esm/locale

See original GitHub issue

Module not found: Can't resolve 'date-fns/esm/locale' in ...'

I’m following the i18n example in the docs

import { es, ru } from 'date-fns/esm/locale'

In a Create React App generated project (ie webpack)

The esm folder does not exist in node_modules and I can only find it as a module value in package.json

How should we import locales?

Issue Analytics

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

github_iconTop GitHub Comments

22reactions
thomasbroduschcommented, Feb 27, 2018

I confirm, there is an error in examples available at https://date-fns.org/:

Replace

import { es, ru } from 'date-fns/esm/locale'

By import en from 'date-fns/locale/en' import ru from 'date-fns/locale/ru'

And it will works like a charm 👌

0reactions
kossnocorpcommented, May 15, 2018

At the moment just a few locales are compatible with v2. See the list: https://github.com/date-fns/date-fns/blob/master/src/esm/locale/index.js. I also fixed a typo in the I18n doc: https://github.com/date-fns/date-fns/pull/741

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Can't resolve '@date-io/date-fns'
I'm using React Material UI and I get this error : Module not found: Can't resolve '@date-io/date-fns'. Here are the dependencies that I...
Read more >
Module not found: Can't resolve '@date-io/date-fns' | bobbyhadz
To solve the error "Module not found: Error: Can't resolve '@date-io/date-fns'", make sure to install the package by opening your terminal in your...
Read more >
date-fns - npm
date -fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
Read more >
date-fns | Yarn - Package Manager
date -fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
Read more >
Can't resolve 'date-fns/_lib/format/longFormatters'
can't resolve 'date-fns/_lib/format/longformatters'. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On July 12, 2021 Popularity ...
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