npx sort-dependencies <path-to-package-dir-or-package.json> --apply
Some toolchains like @microsoft/rush or pnpm make changes to package.json
dependencies without keeping the alphabetical order. This can also happen when doing manual changes of course.
The problem arises when tools like pnpm publish
in combination with rush then sort the dependencies alphabetically but don't commit it back leaving a dirty repo which causes pnpm
to abort publishing.
sort-dependencies
is thus useful in
I also could somehow not find another package that did this the way I liked. prettier-package-json was close but did way more and also reordered the the root properties themselves which I did not like.