next.jsversioningmonorepoyarn-workspaces

yarn monorepo with multiple versioning files, fix yarn version check or reset


Given the following state of my NextJS monorepo app:

yarn version check
➤ YN0001: UsageError: Your current branch contains multiple versioning files; this isn't supported:
- /Users/tbutcaru/Projects/my-nextjs-app/.yarn/versions/00648a82.yml
- /Users/tbutcaru/Projects/my-nextjs-app/.yarn/versions/009a6542.yml
- /Users/tbutcaru/Projects/my-nextjs-app/.yarn/versions/018f7b67.yml
- /Users/tbutcaru/Projects/my-nextjs-app/.yarn/versions/0197a805.yml
    at h (/Users/tbutcaru/Projects/my-nextjs-app/.yarn/plugins/@yarnpkg/plugin-version.cjs:5:3539)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
....

Same issue here and here - closed without solution. I've already tried what others have said through comments in the mentioned links.

I've tried:

... none of the above worked.

How can I fix the "multiple versioning files" issue? Or, at least, how do I completely reset/reinit the yarn workspace packages versions on the main branch?

Thank you!


Solution

  • I didn't find any solution to my issue with the initial setup described in the original post, but I've manage to fix the yarn version check --interactive with a .yarnrc.yml config change!

    I'll try to provide a bit more context on the issue and solution.

    Recently I've changed my repo's default branch from develop to main and that's how I've ended up with the issue above. The idea behind the default branch switch was to move to main and archive develop forever and that created a task of removing all codebase and configs related to develop.

    So, while working on removing any develop branch leftovers from my repo, I've reached to .yarnrc.yml which had the following config:

    changesetBaseRefs:
      - develop
      - origin/develop
      - upstream/develop
    

    ... changing it to:

    changesetBaseRefs:
      - main
      - origin/main
      - upstream/main
    

    ... resulted in yarn version check --interactive and yarn version check to work!