volta icon indicating copy to clipboard operation
volta copied to clipboard

`pnpm run` scripts doesn't use Node version specified in package.json

Open mb21 opened this issue 2 months ago • 2 comments

I'm on volta 2.0.2 on macOS 15.7.1

With this package.json:

{
  "name": "my-website",
  "scripts": {
    "start": "node --version"
  },
  "volta": {
    "node": "24.9.0"
  }
}
pnpm run start

prints v22.19.0 (the one from ~/.volta/tools/image/node/22.19.0/bin/node). The weird thing is, that's not even the default I set with volta install. No idea where it's getting that version from. What it worse, if I rm -r ~/.volta/tools/image/node/22.19.0/, running the script redownloads it!

npm run start correctly prints out v24.9.0.

My actual use-case is to have node ./src/index.js in there. Perhaps there's a workaround?

mb21 avatar Oct 14 '25 13:10 mb21

When I put echo $PATH in that scripts tag and run it with pnpm run start, I see that compared to my normal PATH, somehow the following entries were added in the beginning:

/Users/me/my-project/node_modules/.bin
/Users/me/.volta/tools/image/packages/pnpm/lib/node_modules/pnpm/dist/node-gyp-bin
/Users/me/.volta/tools/image/node/22.19.0/bin

The first one is of course set by pnpm, but where do the other two come from? Seems like a volta bug?

mb21 avatar Oct 15 '25 08:10 mb21

Oh, this seems to be a variation on https://github.com/volta-cli/volta/issues/1562 If I volta uninstall pnpm and reinstall, then it has that version. Feel free to close as duplicate.

mb21 avatar Oct 16 '25 08:10 mb21