Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Since v0.34.4 Yarn installs two different versions of Vite. #4112

Closed
6 tasks done
jgerigmeyer opened this issue Sep 11, 2023 · 4 comments
Closed
6 tasks done

Since v0.34.4 Yarn installs two different versions of Vite. #4112

jgerigmeyer opened this issue Sep 11, 2023 · 4 comments

Comments

@jgerigmeyer
Copy link

Describe the bug

This PR in v0.34.4 introduced a union operator (||) for the Vite dependency to include support for Vite v5.0. Because of how Yarn handles union operators, this means that any Yarn project specifying a dependency on Vite v4 and Vitest v0.34.4 will end up with two different versions of Vite installed.

In other words, this package.json:

{
  "dependencies": {
    "vite": "^4.4.9"
  },
  "devDependencies": {
    "vitest": "^0.34.4"
  }
}

Results in this output from yarn why vite:

➜ yarn why vite
├─ root-workspace-0b6124@workspace:.
│  └─ vite@npm:4.4.9 [dc3fc] (via npm:^4.4.9 [dc3fc])
│
├─ vite-node@npm:0.34.4
│  └─ vite@npm:4.4.9 [dc3fc] (via npm:^4.4.9 [dc3fc])
│
├─ vitest@npm:0.34.4
│  └─ vite@npm:5.0.0-beta.1 (via npm:^3.1.0 || ^4.0.0 || ^5.0.0-0)
│
└─ vitest@npm:0.34.4 [dc3fc]
   └─ vite@npm:5.0.0-beta.1 [1bd26] (via npm:^3.1.0 || ^4.0.0 || ^5.0.0-0 [1bd26])

Reproduction

https://github.com/jgerigmeyer/vitest-vite-version

System Info

System:
    OS: macOS 13.5.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 112.77 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.0.0 - ~/.nvm/versions/node/v20.0.0/bin/node
    Yarn: 3.6.3 - ~/.yarn/bin/yarn
    npm: 9.6.4 - ~/.nvm/versions/node/v20.0.0/bin/npm
  Browsers:
    Chrome: 116.0.5845.179
    Chrome Canary: 119.0.6002.0
    Firefox: 115.0.2
    Safari: 16.6
  npmPackages:
    vite: ^4.4.9 => 4.4.9
    vitest: ^0.34.4 => 0.34.4

Used Package Manager

yarn

Validations

@belgattitude
Copy link

Could see as well (yarn 4rc50) although it doesn't break my tests.

    "vite": "4.4.9",
    "vitest": "0.34.4",
yarn why vite

├─ vite-node@npm:0.34.4
│  └─ vite@npm:4.4.9 [df6da] (via npm:^3.0.0 || ^4.0.0 [df6da])
│
├─ vitest@npm:0.34.4
│  └─ vite@npm:5.0.0-beta.1 (via npm:^3.1.0 || ^4.0.0 || ^5.0.0-0)
│
├─ vitest@npm:0.34.4 [5f667]
│  └─ vite@npm:5.0.0-beta.1 [f68a6] (via npm:^3.1.0 || ^4.0.0 || ^5.0.0-0 [f68a6])
│
└─ web@workspace:.
   └─ vite@npm:4.4.9 [5f667] (via npm:4.4.9 [5f667])

@pongells
Copy link

yeah, it's been happening for a while, seemingly random... very annoying.. as a workaround you can fix the version of vite via resolutions

  "resolutions": {
    "vite": "4.4.9"
  },

@sheremet-va
Copy link
Member

I am honestly not sure how package managers resolve this, but since this is the correct semver string, I would assume they support it.

I am open to any changes that would fix this problem.

@sheremet-va
Copy link
Member

Vitest doesn't use || in the version anymore.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2024
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants