You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] package.json and package-lock.json order is different when used Czech locale #2829
package-lock and package.json order is different when used non English (Czech) locale
Expected Behavior:
Sorting should be locale-agnostic to not change package-lock JSON back and forth.
Steps To Reproduce:
Clone repo created with English locale
Run npm install
I see different order for packages with ch in name (eg. chai)
Environment:
OS: macOS 11.2.2
Node: 14.16.0
npm: 7.6.1
It looks like similar problem as it's reported here npm/npm#17048
I think the root cause is different order of letters. In Czech alphabet CH letter stands after H, but in English alphabet it's just C.
Example in package.json (left is Czech locale, right is English)
Workaround
If someone is facing the same issue in can be fixed by defining alias alias npm='LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8" npm' in bash_profile/.zshrc or similar file depends to shell you are using.
Reacted by Denis Sokolov, Kaido Hallik, padinko and pe4k
Activity
padinko commentedon May 4, 2021
same in Windows 10 with Slovak language, node v14.16.1, npm v7.11.2
i can't find workaround for windows
padinko commentedon May 5, 2021
I make pull requests to fix this
npm/arborist#276 will fix sorting in
package.jsonisaacs/json-stringify-nice#5 will fix sorting in
package-lock.jsonso this 2 packeses will need to be updated to fix this
wraithgar commentedon May 5, 2021
Thank you @padinko!
guard against locale-specific sorting
force 'en' locale in string sorting
Avoid locale-specific sorting issues
Make sort locale independent
Specify 'en' locale to String.localeCompare
Avoid locale-dependent sorting issues
Avoid locale-specific string sorting issues
guard against locale-specific sorting
guard against locale-specific sorting
Avoid locale-specific string sorting issues
Avoid locale-specific string sorting issues
Avoid locale-specific string sorting issues
Avoid locale-specific string sorting issues
fix(add): Specify 'en' locale to String.localeCompare (#3)
guard against locale-specific sorting
guard against locale-specific sorting
Avoid locale-specific string sorting issues
guard against locale-specific sorting
fix(packages): locale-agnostic string sorting
jakubjosef commentedon Jul 28, 2021
I can confirm this is now fixed in NPM. Thank you, closing this issue.