question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: MomentLocalesPlugin: Moment.js doesn’t include a locale you specified: de-ch.

See original GitHub issue

Hi

I use the nuxt moment module like this:

modules: [
    '@nuxtjs/proxy',
    '@nuxtjs/axios',
    ['@nuxtjs/moment', { locales: ['de-ch'], defaultLocale: 'de-ch' }],
    ...

Which seems to work, but as soon as I change something to the nuxt.config.js I get the following error:

Error: MomentLocalesPlugin: Moment.js doesn’t include a locale you specified: de-ch. Check the plugin’s localesToKeep option. You can see the full list of locales that Moment.js includes in node_modules/moment/locale/

I think the locales array is actually the localesToKeep, am I right? So it is actually not missing…

I also checked the locale itself. Normally I would expect it to be de-CH but moment has a file de-ch in which it is also called directly de-ch – all lowercase. Changing the locale to ‘de’ does not resolve the issue either.

What am I missing? Thanks for your help.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
Kinvarascommented, May 16, 2019

Well if this is a blocking issue for you (I mean, being forced to stop and start manually again and again IS some sort of blocking issue to me 😄), there is a temporary workaround:

Just create your own module:

// modules/moment-reset.js
import moment from 'moment';

module.exports = function momentResetModule(moduleOptions) {
  moment.locale('en');
};

And inject it in your nuxt.config.js modules property BEFORE you inject @nuxtjs/moment:

// nuxt.config.js
module.exports = {
  // ...
  modules: [
    // ...
    '@/modules/moment-reset',
   [ '@nuxtjs/moment', ['de-ch']],
    // ...
  ],
  // ...
};

This simple module is in charge of resetting your moment instance to the “en” locale (which is built into moment by default). I guess you have your own plugin to initiate moment to your desired locale (in your case “de-ch”).

If you have a better workaround, this would be interesting 😉

Thx

2reactions
mrleblanc101commented, Oct 11, 2019

Any update on this ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

MomentLocalesPlugin: Moment.js doesn't include a locale you ...
Error : MomentLocalesPlugin: Moment.js doesn't include a locale you specified: ua. Check the plugins localesToKeep option #8012.
Read more >
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-locales-webpack-plugin - npm
Start using moment-locales-webpack-plugin in your project by running ... Easily remove unused Moment.js locales when building with webpack ...
Read more >
Beginning JavaScript I18n with i18next and Moment.js | Phrase
A simple singleton with a supported property and a couple of helpful methods for checking support and locale output can get us started....
Read more >
Moment.js documentation - DevDocs
You must make a new compelling argument for locale changes with significant, non-anecdotal evidence to support your position. If the string or format...
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