moment-module: Error: MomentLocalesPlugin: Moment.js doesn’t include a locale you specified: de-ch.
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
localesToKeepoption. 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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 15 (5 by maintainers)
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:
And inject it in your nuxt.config.js modules property BEFORE you inject @nuxtjs/moment:
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
Any update on this ?
I thought things maybe have changed since the docs now say to use
buildModulesand I thought there was an update on this issue as well or may have changed the loading behaves…The problem still remains though. I added your moment-reset and at least for the first rebuild it worked. I hope it continues to do so.