Skip to content

Yarn requires yarn release .cjs file to be committed to git repo #5748

Description

@ildella

Self-service

  • I'd be willing to implement a fix

Describe the bug

When I upgrade a project to use yarn canary, it downloads the yarn release file in a local project folder, and writes the path in the .yarnrc.yml. The upgrade to yarn v4 is then successful.

I do not push the released file to git as I consider a very bad practice to pollute all my repositories with dependencies file of any kind.

Then when someone else tries to run yarn, it fails as any yarn command will look for the local file - which does not exists on git.

It should be downloading it if there's no local copy.

To reproduce

  1. upgrade a yarn 1.x project to yarn canary following the step by step guide: https://yarnpkg.com/migration/guide
  2. gitignore the whole .yarn/* folder
  3. now everything works, commit and push
  4. someone else - maybe the github workflow - checks out the project and try to run yarn - really any command even --version:
node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module '/{path-to-project}/.yarn/releases/yarn-4.0.0-rc.51.cjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.7.0

Environment

System:
    OS: Linux 6.2 Ubuntu 23.04 23.04 (Lunar Lobster)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
  Binaries:
    Node: 20.7.0 - /tmp/xfs-a472fb66/node
    Yarn: 4.0.0-rc.51 - /tmp/xfs-a472fb66/yarn
    npm: 10.1.0 - ~/n/bin/npm
  npmPackages:
    jest: ^29.7.0 => 29.7.0

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions