pnpm: PNPM is not using the node version set via pnpm env use

pnpm version: 6.25.0

Code to reproduce the issue:

.npmrc

engine-strict = true

Slice of package.json

"engines": {
    "node": ">=16"
  },
❯ pnpm env use --global 16
Node.js 16.13.1 is activated
  /Users/stickb/Library/pnpm/node -> /Users/stickb/Library/pnpm/nodejs/16.13.1/bin/node
❯ pnpm i
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Your Node version is incompatible with "/Users/stickb/Code/green-boost".

Expected version: >=16
Got: v14.18.2

This is happening because the package's manifest has an engines.node field specified.
To fix this issue, install the required Node version.
❯ node -v
v16.13.1

Expected behavior:

pnpm should use version of node that it set

Actual behavior:

pnpm uses another version of Nodejs

Additional information:

  • node -v prints: 16.13.1
  • Windows, macOS, or Linux?: macOS

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 21
  • Comments: 28 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@bestickley what happens if you do pnpm add -g pnpm after doing pnpm env use --global 16

Sorry, the initial issue was fixed, so you need to create a new issue with exact steps to reproduce.

At the moment, I don’t really have ideas why this doesn’t work (maybe we can add some more debug information to the error message).

Also, I think as a workaround, you may put an .npmrc to the root of your project with the following configuration:

use-node-version=18.2.0

NOTE: You should use an exact version for this setting.

I think it should still work without running pnpm i -g pnpm

I had the same issue as @bestickley and I was able to fix it thanks to @PabloSzx comment (thanks 👏 ):

do pnpm add -g pnpm after doing pnpm env use --global 16

Error:

Your Node version is incompatible with "/Users/germanquinteros/...".

Expected version: 16.x
Got: v14.17.0

This is happening because the package's manifest has an engines.node field specified.
To fix this issue, install the required Node version.

Environment:

nvm: 0.38.0
node: v16.13.2
pnpm: 6.30.0

.npmrc

always-auth=true
engine-strict=true
shamefully-hoist=true
enable-pre-post-scripts=true

package.json

  "engines": {
    "node": "16.x"
  },

None of the other solutions here worked for me, but adding this line to my .npmrc file did fix it:

use-node-version=18.19.0

I experienced this issue right now. After upgrading from node v14 to v16 via nvm I was unable to do pnpm install.

Got the same error

...
Expected version: >=16
Got: v14.18.2

After doing pnpm add -g pnpm I can install dependencies.

I’m currently facing this issue

node -v
# v16.18.0
pnpm -v
#7.14.0
pnpm doctor
WARN  Load npm builtin configs failed. If the prefix builtin config does not work, you can use "pnpm config ls" to show builtin configs. And then use "pnpm config --global set <key> <value>" to migrate configs from builtin to global.

None of the other solutions here worked for me, but adding this line to my .npmrc file did fix it:

use-node-version=18.19.0

Fixed it for me in my monorepo using Volta.

Seems like the volta node is used at the root, but the global node is used for apps & packages. use-node-version seems to force it for everything.

@Deebster I see. I was able to reproduce it as well. I’ll look into it.

I did not achieved to solve this issue even if nvm was using v16 properly (PNPM complaining about being stuck at node 12). Uninstalled and re-installed it properly with Corepack and now it’s working great.

PS: Wasn’t working with a curl reinstall neither (was using node 14 for some reason while I had a engine version specified in my package.json)

Same here, wonder why pnpm i -g pnpm is necessary.

pnpm store prune && pnpm i

Same issue for me ~ pnpm add -g pnpm Nothing to stop. No server is running for the store at /home/felix/.local/share/pnpm/store/v3 Already up to date Progress: resolved 1, reused 1, downloaded 0, added 0, done Done in 1.4s pnpm env use --global 18 Fetching Node.js 18.15.0 ... Node.js 18.15.0 is activated pnpm install [sudo] password for felix:  WARN  Unsupported engine: wanted: {"node":">=18"} (current: {"node":"v16.17.0","pnpm":"8.1.0"})

update: this fixed it for me ! https://github.com/pnpm/pnpm/issues/5266#issuecomment-1230366384

The problem is still happening for me on 7.3.0. Had to globally install pnpm after setting the env setting, like @PabloSzx suggested.

today I needed to do this: corepack enable corepack prepare pnpm@<version> --activate pnpm env use --global <version> then pnpm i worked after npm init svelte my-app

@PabloSzx, this worked! Thank you very much. Documenting output here:

❯ node -v
v14.18.2
❯ pnpm env use --global 16
Node.js 16.13.2 is activated
  /Users/stickb/Library/pnpm/node -> /Users/stickb/Library/pnpm/nodejs/16.13.2/bin/node
❯ pnpm i
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Your Node version is incompatible with "/Users/stickb/Code/green-boost".

Expected version: >=16
Got: v14.18.2

This is happening because the package's manifest has an engines.node field specified.
To fix this issue, install the required Node version.
❯ pnpm add -g pnpm
Nothing to stop. No server is running for the store at /Users/stickb/.pnpm-store/v3
gb-cli is linked to /Users/stickb/Library/pnpm/nodejs/14.18.2/pnpm-global/5/node_modules from /Users/stickb/Code/green-boost/packages/gb-cli
gb-lib is linked to /Users/stickb/Library/pnpm/nodejs/14.18.2/pnpm-global/5/node_modules from /Users/stickb/Code/green-boost/packages/gb-lib
Packages: +2
++
Progress: resolved 211, reused 210, downloaded 1, added 2, done

/Users/stickb/Library/pnpm/nodejs/14.18.2/pnpm-global/5:
+ pnpm 6.26.1
❯ pnpm i
Scope: all 4 workspace projects
Lockfile is up-to-date, resolution step is skipped
Already up-to-date
❯ pnpm -v
6.26.1