`pnpm run` scripts doesn't use Node version specified in package.json
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?
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?
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.