Skip to content

changeset version reformats package.json files #1434

Closed

Description

@talkohavy

Problem

when running npm changeset version, the package.json file is being formatted.
The formatting turns this:

"files": ["dist"],

to this:

"files": [
    "dist"
],

This formatting is WRONG.
A. Why does it need to happen?
B. What is causing the formatting?

I have no husky, I have no prettier. I am using VSCode, and the formatOnSave is disabled.
This is a very small project created today.

This is a HUGE ISSUE for me

Activity

  1. with-heart commented on Aug 8, 2024

    @with-heart
    Contributor

    B. That's how JSON.stringify stringifies JSON when using the space parameter.

    A. If the space parameter isn't used, JSON.stringify stringifies JSON as a single line.

    You can see the difference here: https://stackblitz.com/edit/vitejs-vite-f9dpnq?file=src%2Fmain.ts

  2. moroshko commented on Nov 20, 2024

    @moroshko

    Is there a way to tell changesets to run a custom npm script that formats the file?
    For example:

    {
      "check": "biome check --write"
    }
    

    It would need to run after changesets updates package.json and before it creates a Pull Request.

  3. talkohavy commented on Nov 20, 2024

    @talkohavy
    Author

    sadly, to this day of writing the comment, there isn't...

    I hate to be doing this in a another package's thread..., but I ended up switching to another tool on npm, called lvlup, which doesn't format your package.json at all, and only works for a single repo (not a monorepo with many packages) and just performs a simple find & replace.

    Full Disclosure ⚠️
    The tool barely has weekly downloads,
    as I am the developer/maintainer of it. I find myself often creating new packages and needed an appropriate tool.

  4. Hugos68 commented on Jan 2, 2025

    @Hugos68

    I have this problem too and it is frustrating, I hope some sort of post publish step in CI becomes available so I can run the formatter, it's annoying getting formatting issues in the main branch every time after publishing.

  5. tk-o commented on Feb 20, 2025

    @tk-o

    You can turn prettier auto-formatting off now with this release:

  6. Hugos68 commented on Feb 20, 2025

    @Hugos68

    @tk-o Awesome, thank you!

  7. with-heart commented on Feb 20, 2025

    @with-heart
    Contributor

    @Andarist I think this can be closed now ❤

  8. shrugs commented on Apr 8, 2025

    @shrugs

    still seeing this behavior despite prettier: false in my changeset config

  9. Hugos68 commented on Apr 9, 2025

    @Hugos68

    @shrugs did you update your changeset package?

  10. beeequeue commented on Apr 30, 2026

    @beeequeue
    Member

    @shrugs if you still have this issue let me know and i'll re-open the issue!

  11. beeequeue commented on Apr 30, 2026

    @beeequeue
    Member

    actually sorry, this is related to the package.json writing which is unaffected by Prettier. i will create an umbrella issue for this later

  12. changed the title [-]npm changeset version command formats the package.json[/-] [+]`changeset version` reformats `package.json` files[/+] on May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions