pnpm: PNPM is (still?) not correctly identifying the node version

pnpm version:

7.9.5

Code to reproduce the issue:

pnpm install

Expected behavior:

installation proceeds as normal

Actual behavior:

ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Additional information:

  • node -v prints:
  • v18.8.0
  • Windows, macOS, or Linux?: Windows 10

This is the same issue as #4203 and was either never fixed or has regressed.

This can be reproduced by downloading the 7.9.5 version from github releases and running pnpm install twice. See attached console log

D:\dev
λ mkdir repro

    Directory: D:\dev

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           8/25/2022  5:19 PM                repro

D:\dev
λ cd repro
D:\dev\repro
λ Invoke-WebRequest https://github.com/pnpm/pnpm/releases/download/v7.9.5/pnpm-win-x64.exe -OutFile pnpm-win-x64.exe
D:\dev\repro
λ .\pnpm-win-x64.exe --version
7.9.5
D:\dev\repro
λ .\pnpm-win-x64.exe create svelte@latest test
../../.pnpm-store/v3/tmp/dlx-18352       |   +5 +
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: D:\.pnpm-store\v3
  Virtual store is at:             ../../.pnpm-store/v3/tmp/dlx-18352/node_modules/.pnpm
../../.pnpm-store/v3/tmp/dlx-18352       | Progress: resolved 5, reused 5, downloaded 0, added 5, done

create-svelte version 2.0.0-next.162

Welcome to SvelteKit!

This is beta software; expect bugs and missing features.

Problems? Open an issue on https://github.com/sveltejs/kit/issues if none exists already.

√ Which Svelte app template? » SvelteKit demo app
√ Add type checking with TypeScript? » Yes, using JavaScript with JSDoc comments
√ Add ESLint for code linting? ... No / Yes
√ Add Prettier for code formatting? ... No / Yes
√ Add Playwright for browser testing? ... No / Yes

Your project is ready!
✔ Type-checked JavaScript
  https://www.typescriptlang.org/tsconfig#checkJs

Install community-maintained integrations:
  https://github.com/svelte-add/svelte-adders

Next steps:
  1: cd test
  2: npm install (or pnpm install, etc)
  3: git init && git add -A && git commit -m "Initial commit" (optional)
  4: npm run dev -- --open

To close the dev server, hit Ctrl-C

Stuck? Visit us at https://svelte.dev/chat

D:\dev\repro
λ cd test
D:\dev\repro\test
λ pnpm install
Packages: +169
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: D:\.pnpm-store\v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 190, reused 169, downloaded 0, added 169, done

dependencies:
+ @fontsource/fira-mono 4.5.9
+ cookie 0.4.2 (0.5.0 is available)

devDependencies:
+ @sveltejs/adapter-auto 1.0.0-next.66
+ @sveltejs/kit 1.0.0-next.442
+ @types/cookie 0.5.1
+ svelte 3.49.0
+ svelte-check 2.8.1
+ typescript 4.7.4
+ vite 3.0.9
D:\dev\repro\test
λ pnpm install
Lockfile is up to date, resolution step is skipped
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Your Node version is incompatible with "/@sveltejs/kit/1.0.0-next.442_svelte@3.49.0+vite@3.0.9".

Expected version: >=16.9
Got: v14.19.2

This is happening because the package's manifest has an engines.node field specified.
To fix this issue, install the required Node version.
D:\dev\repro\test
λ node -v
v18.8.0

About this issue

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

Commits related to this issue

Most upvoted comments

Experiencing the same on Arch linux and pnpm 7.9.5.

Steps to fix :-

  1. Created .npmrc with use-node-version=18.8.0
  2. ran pnpm i

output:

Fetching Node.js 18.8.0 ...
Node.js 18.8.0 is activated
  $InstallDir/pnpm/node -> /home/$User/.local/share/pnpm/nodejs/18.8.0/bin/node

Fixed the issue for me.

I also had this issue

  • pnpm version 7.14.2 (installed via homebrew on macOS 13, but updated over time with pnpm add -g pnpm)
  • run pnpm env --global 18
  • node -v returns 18
  • commands ran via pnpm give engine warnings
  • but things like pnpm node run the correct node version but still print the warning

Fixed the issue by running pnpm add -g pnpm

macOs Ventura 13.2.1 Using Volta to switch node versions between projects. 14 16 and 18 pnpm seems to be stuck on the node version it was installed globally at the time. Reinstalling pnpm -g while having the desired version works as a hack.

I doubt this is the case, as I have never installed Node v14.19.2 (or a version close). That, and it seems as though a lot of people have experienced this issue randomly - it’s extremely unlikely that everyone had exactly Node v14.19.2 when they installed pnpm, IMO.

Also running into something like this when trying to have pnpm coexist with volta.

While having pnpm manage the node version is a noble mission, it seems that the existence of the (what should be optional) feature is somehow making things more complex instead of less… 😦

More details:

Running which node results in something like /Users/theo/.volta/bin/node (which lets volta manage the version). But adding "whichnode": "which node" to package.json scripts and running pnpm run whichnode) results in something like /Users/theo/.volta/tools/image/node/18.16.0/bin/node

While adding a specific node version in .npmrc file does tell pnpm which pnpm-managed version to use, I do not think this should be a requirement. From the behaviour above, it seems that pnpm is trying to fallback to whatever version is running locally, and while that seems reasonable, it seems to be somehow resolving the version that is running during install.

(sidenote - re-running volta install pnpm seems to at least reset it, the same way a pnpm install -g pnpm would, but keeping things in volta land)

The same happened in windows on pnpm v7.26.0. And can’t run pnpm add -g pnpm.

Screenshot 2024-01-10 at 6 44 18 PM

Just another data point here. I’m also having this issue. On the latest pnpm. I don’t use n, nvm or any other node manager. 18.5 does not exist on my system. I have no idea where pnpm is pulling that version from.

The fix for me was uninstalling pnpm and reinstalling it via npm. I had originally installed via curl. I did not have multiple means of managing node versions and had never installed 18.5.

I do not have a version that is even remotly close to 18.5.0 installed on my system and I also have no idea where pnpm is pulling that from. The issue started just now and hasn’t been an issue in the past.

I want to point out that many of us are getting the same exact Node version mentioned by pnpm:

I explained why that is a few comments up: https://github.com/pnpm/pnpm/issues/5266#issuecomment-1921587990

TL;DR: pnpm comes bundled with 18.5.0 when installed through the convenience script.

Screenshot 2024-01-10 at 6 44 18 PM Just another data point here. I'm also having this issue. On the latest pnpm. I don't use n, nvm or any other node manager. 18.5 does not exist on my system. I have no idea where pnpm is pulling that version from.

I believe this is still an issue on pnpm 8.10.5 when installed as a standalone.

Running pnpm install with engine-strict=true set in .npmrc resolves to a “random” node version.

Note: running pnpm add -g pnpm after pnpm env use or setting the use-node-version option in .npmrc “fixes” the issue but I guess it should work without workarounds.

Screenshot 2023-11-21 at 12 29 24

There’s also an issue running inside GitHub Workflow. It seems like pnpm is not recognizing that the Node version already exists and updated.

We have actions/setup-node@v3 configured to set the exact version.

But then pnpm tries to update again for some reason.

screenshot-20230927T122122-Uu0pjTEV@2x

Modify that file and add which node to see where it is locating node.

pnpm usually runs from a bin stub shell script for me…I found that earlier versions hard-coded the node version.

You should also check if you use pnpm env.

This script is usually at /Users/Vaughan/Library/pnpm/pnpm. If /Users/Vaughan/Library/pnpm/node exists, it will use that.

Experiencing the same on macOS and pnpm 7.9.5.

Regardless of my env use --global setting, it’s always using v14.x