volta-cli / volta

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

`pmpm` uses the `node` version it was installed it instead of currently active/pinned version #1562

Open nifr opened 11 months ago

nifr commented 11 months ago

Given volta's active node version is i.e. v20.8.1 When I install pnpm with volta And I install and pin a different node version i.e. v21.0.0 Then pnpm still uses the previous node version v20.8.1

Steps to reproduce:

volta install node@20.8.1
volta install pnpm@8.9.2
volta install node@21.0.0
volta pin node@21.0.0
pnpm run dev

With package.json containing:

  "packageManager": "pnpm@8.9.2",
  "volta": {
    "node": "21.0.0"
  },
  "engines": {
    "node": "21.0.0",
    "pnpm":"8.9.2"
  }

The following warning appears and reveals that the incorrect node version is used under the hood:

WARN  Unsupported engine: wanted: {"node":"v21.0.0"} (current: {"node":"v20.8.1","pnpm":"8.9.2"})
runspired commented 11 months ago

Also hitting this with pnpm 8.9+ and volta (yes VOLTA_FEATURE_PNPM=1 is set)

lananelson commented 10 months ago

+1 and I cannot uninstall Node that volta installed

chawyehsu commented 10 months ago

I can't reproduce with steps that OP posted. I may be able to take this issue on but I need a certainly reproducible way to reproduce.

volta install node@20.8.1
volta install pnpm@8.9.2
volta install node@21.0.0
volta pin node@21.0.0
volta pin pnpm@8.9.2
pnpm run dev
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "node index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "volta": {
    "node": "21.0.0",
    "pnpm": "8.9.2"
  }
}
theodesp commented 10 months ago

VOLTA_FEATURE_PNPM=1

I got this working with this export:

❯ pnpm install  WARN  Unsupported engine: wanted: {"node":">=18"} (current: {"node":"v16.20.0","pnpm":"8.6.2"}) Lockfile is up to date, resolution step is skipped Already up to date

datree@0.0.1 prepare /Users/theo.despoudis/Workspace/datree husky install

husky - Git hooks installed Done in 1.2s ❯ export VOLTA_FEATURE_PNPM=1 ❯ pnpm install Lockfile is up to date, resolution step is skipped Already up to date

datree@0.0.1 prepare /Users/theo.despoudis/Workspace/datree husky install

husky - Git hooks installed Done in 1.1s

malfianrasyidin commented 8 months ago

I also experience the same issue with the pnpm@7.33.6 and volta@1.0.5.

The project has declared the node@18.12.1, shown in the picture below, with node -v. While executing the pnpm node -v, the node version used was node@18.19.0, which was the node version used when installing the pnpm.

Let's say we run the NextJS project with the pnpm dev; then the node version is attached to the pnpm, not the one declared in the project itself.

I have also tried adding the global environment variable stated in https://docs.volta.sh/advanced/pnpm; it looks like the feature is still experimental.

I would appreciate it if someone could help with this issue; thank you!

image

chawyehsu commented 8 months ago

I also experience the same issue with the pnpm@7.33.6 and volta@1.0.5.

The project has declared the node@18.12.1, shown in the picture below, with node -v. While executing the pnpm node -v, the node version used was node@18.19.0, which was the node version used when installing the pnpm.

Let's say we run the NextJS project with the pnpm dev; then the node version is attached to the pnpm, not the one declared in the project itself.

I have also tried adding the global environment variable stated in https://docs.volta.sh/advanced/pnpm; it looks like the feature is still experimental.

I would appreciate it if someone could help with this issue; thank you!

image

You are using volta v1.0.5 while the VOLTA_FEATURE_PNPM feature support was introduced in Volta v1.1.1...

malfianrasyidin commented 8 months ago

I also experience the same issue with the pnpm@7.33.6 and volta@1.0.5. The project has declared the node@18.12.1, shown in the picture below, with node -v. While executing the pnpm node -v, the node version used was node@18.19.0, which was the node version used when installing the pnpm. Let's say we run the NextJS project with the pnpm dev; then the node version is attached to the pnpm, not the one declared in the project itself. I have also tried adding the global environment variable stated in https://docs.volta.sh/advanced/pnpm; it looks like the feature is still experimental. I would appreciate it if someone could help with this issue; thank you! image

You are using volta v1.0.5 while the VOLTA_FEATURE_PNPM feature support was introduced in Volta v1.1.1...

You are right, @chawyehsu, thank you. The docs should have mentioned the minimum version of the Volta itself.

olja-ivkovic commented 6 months ago

I had the same issue even with Volta v1.1.1 and VOLTA_FEATURE_PNPM flag enabled, but managed to fix it by uninstalling pnpm and installing it again while node 20.11.0 was pinned.

So just:

volta uninstall pnpm
volta pin node@20.11.0

( or volta install node@20.11.0 to have it as a default node version )

volta install pnpm

And now this command finally tells me that pnpm uses my desired node version:

pnpm node --version
> 20.11.0
mfwgenerics commented 3 months ago

Seeing this too. The uninstall/reinstall workaround works for me.