pkg
pkg copied to clipboard
Other locales than english are not supported in pkg generated executables
What version of pkg are you using?
5.5.2
What version of Node.js are you using?
16.13.0
What operating system are you using?
Debian GNU/Linux 11 (bullseye)
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node16-win-x64, node16-linux-x64
Describe the Bug
I am using functions that are part of Node.js and accept a locale
to be provided. So when I do new Date().toLocaleDateString('de-DE', {weekday: 'long'})
I expect the output to be Montag
instead of Monday
.
But for some reasons Node.js inside the executable generated by pkg does not contain other locales and falls back to English instead.
This causes some nasty bugs that haven't been caught by my tests. This affects Intl.NumberFormat
and probably all the other methods too.
Expected Behavior
To support other locales like de
(German) like it would if Node.js is installed normally on a system
To Reproduce
- Create a index.js file (empty directory) with:
console.log(Intl.NumberFormat.supportedLocalesOf('de'));
console.log(Intl.NumberFormat.supportedLocalesOf('de-DE'));
console.log(Intl.NumberFormat.supportedLocalesOf('xx'));
console.log(new Date().toLocaleDateString('de-DE', {weekday: 'long'}));
-
Run
npx pkg -t node16-linux-x64 index.js
-
Run
./index
andnode ./index.js
You should see different outputs (this happens on node16-win-x64
too)
This seems to be related to this issue: https://github.com/vercel/pkg/issues/1563
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.
For reference #1731 #1749
Here's a working example/solution to get correctly formatted dates with pkg
: https://github.com/vercel/pkg/issues/1731#issuecomment-1317191357