17.4.2024
I was about to work on a project that uses pnpm. Unfortunately the lock file was version 6 which is no longer supported by the current pnpm (version 10.8.1).
There was no .nvmrc
or .node-version
file in the repo. So to make sure I use the same setup as other developers, I asked about what node version they used.
Then I wanted to fix the node version and the pnpm version in the repo through a config file. I use fnm
for node version management but I could not figure out how to fix the pnpm
verision. Looks like there is no way.
But I acidentally disovered that pnpm can also manage node versions through
useNodeVersion: 22.14.0
property of pnpm-workspace.yamluse-node-version=22.14.0
property in .npmrc
The interesting thing about it is that you do not need to do anything after setting it up. Any command you run with pnpm will automatically use the specified version under the hood. So no need for global setup of nodejs. Nice!