Skip to content

[Bug] The npx changeset version command does not work correctly if the prettier key is specified in package.json #1649

Closed

Description

@alSergey

Describe the bug

If the prettier key is present in package.json and it specifies a non-existent package, the npx changeset version command cannot create CHANGELOG.md files and fails with an error. The exit code is 0.

> npx changeset version && echo $?

Error: Cannot find module 'some-package'
Require stack:
- /Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/prettier/index.js
- /Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/write/dist/changesets-write.cjs.js
- /Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/cli/dist/changesets-cli.cjs.js
- /Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/cli/bin.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
    at resolve (node:internal/modules/helpers:145:19)
    at Object.transform (/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/prettier/index.js:18425:34)
    at run (/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/prettier/third-party.js:8418:53)
    at async cacheWrapper (/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/prettier/third-party.js:8294:22)
    at async Explorer.search (/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/prettier/third-party.js:8407:24)
    at async Promise.all (index 0)
    at async writeFormattedMarkdownFile (/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/apply-release-plan/dist/changesets-apply-release-plan.cjs.js:461:76)
    at async updateChangelog (/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/apply-release-plan/dist/changesets-apply-release-plan.cjs.js:435:7)
    at async Object.applyReleasePlan [as default] (/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/apply-release-plan/dist/changesets-apply-release-plan.cjs.js:351:7) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/prettier/index.js',
    '/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/write/dist/changesets-write.cjs.js',
    '/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/cli/dist/changesets-cli.cjs.js',
    '/Users/seralekhin/Desktop/changesets-prettier-error-repro/node_modules/@changesets/cli/bin.js'
  ]
}
🦋  All files have been updated. Review them and commit at your leisure
0

Expected behavior

Command npx changeset version fails with error, exit code 0

Current behavior

The command npx changeset version does not fail with an error, exit code 0

Reproduction

  1. Clone repo changesets-prettier-error-repro
  2. Download dependencies npm ci
  3. Run command npm run up

Activity

  1. bluwy commented on Apr 26, 2025

    @bluwy
    Member

    That's because changesets formats with prettier internally and the config is respected. If it's a string, it'll try to import it. Is there a reason you've set that value?

    You can also disable prettier formatting with the prettier: false option in .changeset/config.json (looks like it hasn't been documented). And there's some movement to make formatting in general more flexible: #1639

  2. alSergey commented on Apr 26, 2025

    @alSergey
    Author

    Okay, is it possible to crash with exit code 1 if formatting with prettier failed?

  3. bluwy commented on Apr 26, 2025

    @bluwy
    Member

    Yeah it should probably exit with 1

  4. added theissue type on Dec 12, 2025
  5. bluwy commented on Jul 1, 2026

    @bluwy
    Member

    This should be fixed in #1994 with exit code 1 returned if formatting fails.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions