volta-cli / volta

Volta: JS Toolchains as Code. ⚡
https://volta.sh
Other
10.32k stars 220 forks source link

Node & package versions #1774

Open nike1v opened 2 weeks ago

nike1v commented 2 weeks ago

I do enjoy using volta now, but I'm facing some kind of inconvenience.

Actual behaviour 1) If VOLTA_FEATURE_PNPM is not set, then using pnpm via globally installed package or via corepack does not trigger installing new node version. since volta do not observe pnpm withot that env. 2) If I use VOLTA_FEATURE_PNPM, then volta use own pnpm instead of corepack (then packageManager field in package.json is unused) 3) If I use VOLTA_FEATURE_PNPM, then I can't use volta uninstall pnpm 4) THE MOST PROBLEMATIC -> if pinned version of node changes, volta installing new one, but do not change binded version for other packages (pnpm, corepack, I'll assume yarn too) if they are installed via volta install <package>.

Expected behaviour 1) If VOLTA_FEATURE_PNPM is not set and user have pnpm installed, trigger node instalation if workspace version is different than installed. 2) If VOLTA_FEATURE_PNPM is set, but pnpm is installed via corepack, take that binnary and use it, do not repeat installation 3) If VOLTA_FEATURE_PNPM is set and pnpm is managed my volta, allow to uninstall pnpm 4) If a new node version is beeing installed (because pinned version changed or user install new default node), swap tool binnaries to the respective node version ex. Node was 20.12.0 and pnpm was 9.1.0, when I change Node to 20.13.0 the pnpm still use 20.12.0 and therefor installation script throws WARN/ERROR that engine is missmatched, because pnpm use old node.

100% better solution is to stop pinning package managers in a volta property in package.json and instead take packageManager field like corepack does.

Also this is a bit weird that you need to install corepack as a separate package, which is causing the same issue like with pnpm, that corepack using node version that was default when it was installed, but node itself contain corepack in the image, why does volta do not use it instead? Is it possible to do some workaround or even fix this behaviours?