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
- Added .npmrc to get around pnpm issue. * https://github.com/pnpm/pnpm/issues/5266 — committed to perfStack/Interactive_comments by perfStack 2 years ago
- fix: correctly detect the active Node js version during headless installation (#7801) close #5266 --------- Co-authored-by: Zoltan Kochan <z@kochan.io> — committed to FairyWorld/devtool_pnpm by dy-dx 3 months ago
- fix: correctly detect the active Node js version during headless installation (#7801) close #5266 --------- Co-authored-by: Zoltan Kochan <z@kochan.io> — committed to pnpm/pnpm by dy-dx 3 months ago
Experiencing the same on Arch linux and pnpm 7.9.5.
Steps to fix :-
use-node-version=18.8.0
output:
Fixed the issue for me.
I also had this issue
pnpm add -g pnpm
)pnpm env --global 18
node -v
returns 18pnpm node
run the correct node version but still print the warningFixed the issue by running
pnpm add -g pnpm
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 runningpnpm 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 apnpm 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.
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 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.
I believe this is still an issue on pnpm
8.10.5
when installed as a standalone.Running
pnpm install
withengine-strict=true
set in.npmrc
resolves to a “random” node version.Note: running
pnpm add -g pnpm
afterpnpm env use
or setting theuse-node-version
option in.npmrc
“fixes” the issue but I guess it should work without workarounds.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.
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