Fixpack: package.json Scrubber

4.0.0 · active · verified Wed Apr 22

fixpack is a command-line interface (CLI) tool designed to enforce a consistent structure and content within `package.json` files. It automates the reordering of top-level keys, alphabetically sorts `dependencies` and `devDependencies`, and ensures a newline at the end of the file. The tool also provides configurable warnings for missing recommended fields (e.g., `description`, `author`, `license`) and errors for missing required fields (e.g., `name`, `version`). A key differentiator is its ability to tolerate malformed JSON using the `alce` library, making it robust against minor syntax errors. The current stable version is 4.0.0, though the project's update cadence appears irregular, with previous major updates and patch fixes spanning several years. It supports extensive configuration via `.fixpackrc` files and CLI arguments, and can be integrated into CI/CD pipelines using its `--dryRun` flag to check for compliance without modifying files.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates global installation and execution of fixpack, including its use in a post-install hook and a dry run for CI checks.

npm i -g fixpack

# Navigate to your project directory
cd my-project

# Run fixpack to clean up package.json
fixpack

# Example of using fixpack after installing a new package
npm i cool_package --save && fixpack

# Check if package.json needs fixing without modifying it (for CI/CD)
# This will exit with code 1 if changes are needed, 0 if already fixed.
fixpack --dryRun

view raw JSON →