Problem with toLocaleString in production nodejs!

Asked

Viewed 428 times

0

Talk guys! I’m having trouble using toLocaleString in production! When using toLocaleString this way

const number = (num / 100).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' });

in mac the return is correct R $ 10.000,00 when climbing to the server in production the return is R $ 10,000.00 Someone’s been through it?

  • 1

    What version do you have local and on the server?

1 answer

0

You can use a module called "full-icu", and then you start Node by setting the NODE_ICU_DATA environment variable by pointing to './node_modules/full-icu'. However, if you use process managers like PM2 in "cluster" mode, it won’t work. I ended up discovering this in some tests here, it also worked local, but the server did not work (just because there is running in cluster mode). But in "Fork" mode it works normally.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.