Numeral-js
Numeral-js copied to clipboard
locales issue with react
i can use the numeral.js within my reactt/next.js project but when i try to use a locale, getting the error:
numeral.locale('tr');
> TypeError: Cannot read properties of undefined (reading 'abbreviations')
With Angular 13 is the same. If you try to get all registered locales you will see that only 'en' is loaded.
any ideas on this?
I ran into similar and noticed something due to way this library is setup - as I was using it in pure esm codebase (ng 13+). When using alongside @types/numeral like this:
import { locale, register } from 'numeral';
import { localeFormat } from './utils';
register('locale', 'nl', localeFormat());
locale('nl');
Would throw this error everytime:
TypeError: Cannot read property 'nl' of undefined
However when used like this:
import * as numeral from 'numeral';
import { localeFormat } from './utils';
numeral.register('locale', 'nl', localeFormat());
numeral.locale('nl');
Everything worked fine.