How to specify pnpm version?

In a Node.js project, I’m attempting to use a specific pnpm version by installing it globally. This leads to some head-scratching behavior:

render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ node --version
v18.13.0
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ pnpm --version
7.6.0
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ which pnpm
/usr/local/bin/pnpm
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ ls -l `which pnpm`
lrwxrwxrwx 1 root root 37 Jul 26 21:36 /usr/local/bin/pnpm -> ../lib/node_modules/pnpm/bin/pnpm.cjs
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ npm i -g pnpm@7.25.0

added 1 package, and audited 2 packages in 4s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ which pnpm
/opt/render/project/nodes/node-18.13.0/bin/pnpm
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ ls -alh `which pnpm`
lrwxrwxrwx 1 render render 37 Jan 17 21:48 /opt/render/project/nodes/node-18.13.0/bin/pnpm -> ../lib/node_modules/pnpm/bin/pnpm.cjs
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ pnpm --version
7.6.0
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ /opt/render/project/nodes/node-18.13.0/bin/pnpm --version
7.25.0
render@srv-cf3gjdha6gdpa6sf86bg-67499cb6-68ctm:~/project/src$ 

Anyone understand what’s going on here? I’m particularly confused by the last couple commands, which seem to indicate that specifying the full path to pnpm yields a different version than running it off your execution $PATH.

Is there a better way to pin a specific pnpm version?

I’m using a fork of Render’s Next.js starter without any particularly interesting changes.

Related: Specify NPM version?

Hi John,

Did you see this comment from the post you linked? You should be able to specify a version of node that has the version of pnpm that you need. Let us know if that doesn’t work for you and we will take a closer look.

Node comes bundled with a version of npm, but not pnpm. I’m not sure where Render’s version comes from, but I suspect it’s somewhere in your infrastructure!

@tyler - in case you weren’t notified of the previous message:

The version of pnpm available on Render is not distributed with Node.js. It comes from somewhere else. Changing Node.js versions doesn’t affect which pnpm you get.

This repro uses the latest Node LTS (18.13.0 from January 2023), but when deployed to Render, I’m seeing a much older pnpm (7.6.0 from July 2022).

Can you determine where Render’s version came from, and how I can install my own?

Hi John,
Sorry for the radio silence here.

When a Node build occurs we run install pnpm at the time of the build after we’ve installed Node with RUN npm install -g pnpm webpack semver @renderinc/fetch-node-version. But what is odd is that installs v7.6!

You can force the newer version by performing npm install -g pnpm in your render-build as per https://github.com/johnbeynonorg/render-nextjs-example/blob/master/render-build.sh#L4 which I confirm gives you the latest:

$ pnpm --version7.26.3

John B

Thanks, @John_B, that works!

I had given up on npm i -g pnpm when I observed that it didn’t take effect in the interactive shell, but sure enough it works from the build script.

For future reference for anyone else stumbling upon this thread, I had found another workaround, too:

mkdir -p bin
corepack enable --install-directory bin
export PATH="$PWD/bin:$PATH"

I’m glad to not have to do this, though :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.