Sort your dependencies!
Dependency management is a crucial aspect of any project.
In the Node.js world, npm is the standard tool for installing and managing dependencies, but let’s not forget its counterparts yarn and pnpm.
package.json file lists all the dependencies and their versions.
When working on a team project, it’s important to maintain the
package.json file consistently.
And that’s where the sort-package-json package comes in.
It allows you to sort the
package.json file alphabetically based on package names.
This ensures consistency in the order of dependencies, making the file more readable and maintainable.
In addition to dependencies, which are sorted by default if you’ve only installed them via command line (
npm install XXX), sort-package-json also sorts other fields in the file, such as author, project name, version, etc.
For this purpose, the package utilizes predefined rules defined here.