pnpm: "ERR_INVALID_THIS" on "pnpm up" in Node 20
pnpm version: 8.3.0
Code to reproduce the issue:
In a pnpm project, install, then run pnpm up
.
An easy repro is just to try it in the pnpm repo itself.
Expected behavior:
No error
Actual behavior:
WARN GET https://registry.npmjs.org/@definitelytyped%2Fdefinitions-parser error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@definitelytyped%2Fdtslint-runner error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@definitelytyped%2Fheader-parser error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@definitelytyped%2Ftypescript-versions error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@definitelytyped%2Futils error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/typescript error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@definitelytyped%2Fdtslint error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@octokit%2Fcore error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/@octokit%2Frest error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/comment-json error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/d3-array error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/d3-axis error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/d3-scale error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/d3-selection error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/d3-time error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
WARN GET https://registry.npmjs.org/d3-time-format error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.
Additional information:
node -v
prints: v20.0.0- Windows, macOS, or Linux?: Linux
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 62
- Comments: 64 (22 by maintainers)
Commits related to this issue
- :green_heart: Use matrix for `node-virsion` See https://github.com/pnpm/pnpm/issues/6424 — committed to neutron0831/nlp100-ts by neutron0831 a year ago
- :green_heart: Set `node-version` to 19 See https://github.com/pnpm/pnpm/issues/6424 — committed to neutron0831/nlp100-ts by neutron0831 a year ago
- fix(publish): 💚 specify node version https://github.com/pnpm/pnpm/issues/6424 — committed to importantimport/a2 by kwaa a year ago
- fix: should work with node.js 20 ref pnpm/pnpm#6424 — committed to pnpm/node-fetch by zkochan a year ago
- fix: should work with node.js 20 (#1) ref pnpm/pnpm#6424 — committed to pnpm/node-fetch by zkochan a year ago
- fix: support development on Node 20 This patches node-fetch so pnpm install works on Node 20: https://github.com/pnpm/pnpm/issues/6424 — committed to nickmccurdy/arktype by nickmccurdy a year ago
- [engsys] Update to latest pnpm 7.x and Rush (#25742) ### Packages impacted by this PR - All ### Issues associated with this PR N/A ### Describe the problem that is addressed by this PR ... — committed to Azure/azure-sdk-for-js by mpodwysocki a year ago
- downgrade node to v18 due to issues with pnpm on netlify https://github.com/pnpm/pnpm/issues/6424 — committed to kulturverein-lochmuehle/website by deleted user a year ago
- chore(deps): update pnpm to v8.5.0 (#2063) Resolves https://github.com/pnpm/pnpm/issues/6424 — committed to nuxt-modules/i18n by dargmuesli a year ago
- downgrade node to v18 due to issues with pnpm on netlify https://github.com/pnpm/pnpm/issues/6424 — committed to kulturverein-lochmuehle/website by davidenke a year ago
- chore: update pnpm versions, default version: 8.10 -> 8.5.1 We update the jq command to sort them by version (and not release date). This is important to keep latest on the same major version (and no... — committed to gzm0/rules_js by gzm0 a year ago
- chore: update pnpm versions, default version: 8.1.0 -> 8.5.1 We update the jq command to sort them by version (and not release date). This is important to keep latest on the same major version (and n... — committed to gzm0/rules_js by gzm0 a year ago
- chore: update pnpm versions, default version: 8.1.0 -> 8.5.1 We update the jq command to sort them by version (and not release date). This is important to keep latest on the same major version (and n... — committed to gzm0/rules_js by gzm0 a year ago
- chore: update pnpm versions, default version: 8.1.0 -> 8.5.1 We update the jq command to sort them by version (and not release date). This is important to keep latest on the same major version (and n... — committed to gzm0/rules_js by gzm0 a year ago
- chore: update pnpm versions, default version: 8.1.0 -> 8.5.1 (#1083) We update the jq command to sort them by version (and not release date). This is important to keep latest on the same major versi... — committed to aspect-build/rules_js by gzm0 a year ago
- [engsys] Update to latest pnpm 7.x and Rush (#25742) ### Packages impacted by this PR - All ### Issues associated with this PR N/A ### Describe the problem that is addressed by this PR ... — committed to minhanh-phan/azure-sdk-for-js by mpodwysocki a year ago
- Fix pnpm `ERR_INVALID_THIS` on Node 20 (#51406) ### What? Fixes pnpm/pnpm#6424 ### Why? So users of Node 20 can contribute to Next.js ### How? Upgrades pnpm with back compatibility to ... — committed to vercel/next.js by nickmccurdy a year ago
- chore(deps): update pnpm to v8.5.0 (#2063) Resolves https://github.com/pnpm/pnpm/issues/6424 — committed to Jarosky/i18n by dargmuesli a year ago
- chore: upgrade pnpm to version that support node 20 (#5609) ### Description Before `pnpm@8.3.1` wasn't compatible with Node 20 (https://github.com/pnpm/pnpm/issues/6424) Fixes #5587 #5592 I c... — committed to vercel/turbo by chris-olszewski a year ago
- chore: bump up pnpm required version. Current version was having problems with Node 20 (see https://github.com/pnpm/pnpm/issues/6424) — committed to Blobscan/blobscan by PJColombo 10 months ago
To help anyone else using pnpm globally installed by pnpm:
Fixed in v8.3.1
In my case pnpm works fine with previous node version (v19.8.1).
Only when I try to use node v20, it throws
(ERR_INVALID_THIS)
I use NVM to change to switch.
corepack prepare pnpm@8.3.1 --activate
did the trick for me, on mac.pnpm was installed with the node/corepack brew package so i didn’t want to use npx as mentioned above (https://github.com/pnpm/pnpm/issues/6424#issuecomment-1515748464).
There are other issues like this, it seems:
Still happening, with pnpm v8.15.3 and node v20.11.0
Still happening for me with pnpm v8.14.0 and node v20.10.0
Can confirm this only seems to happen on the latest node 20 and using a previous version (19.9.0 in my case) it works fine.
Getting:
ERR_INVALID_THIS
as well as:ERR_PNPM_META_FETCH_FAIL GET https://registry.npmjs.org/packagename: Value of "this" must be of type URLSearchParams
I’m still getting this error when deploying to my Render.com instance with Node 20 enabled.
Even using corepack does not solve the issue.
This should definitely not be closed
To me a newer version of pnpm helped. I had to install it using
npm install -g pnpm --force
if I recall correctly. I had to use force because else there was some error which I of course did not read but the error suggested using force so I did. May the --force be with you!This doesn’t appear to be fully fixed unless I’m missing something- I’'m running on a Mac and have updated to the latest but it still persists. – hold that thought, IntelliJ is giving me a different version than outside. Probably my issue. UPDATE: fixed. The version pulled by npx is not up to date. On a Mac I had to upgrade via home-brew and use it to override symlinks.
Very strange… in my case nothing worked for me until I used:
yarn global add pnpm@latest
why don’t you use native ‘fetch’? So wouldn’t you be avoiding problems like this in the future?
Still happen with pnpm 9.0.6 and node v20.11.1
You can use
corepack up
to update your pnpm version andpackageManager
inpackage.json
in one step.I’m finding this issue on Apple M2 Pro while using nektos/act with pnpm 8.10.0 and node v20.9.0
Its probably executing pnpm from cache causing the same issue.
npx pnpm@latest i -g pnpm@latest
should do the trick. Or just installnpm i -g pnpm@latest
directly.I updated to node v20 last night using
and faced similar issues but the problem is now I cannot even go back to node v19 or v18
gives
I get it when using
pnpm install
on node version 21 and I’m using pnpm version 8.8.0.This issue does happen inside github actions when using act to run them locally. Annoying…
even with standalone script installation via the action
For those who have the same problem just revert your node installation to v18.17.0
native fetch is not present in node.js v16. And even in node.js v18 it is experimental. So, we cannot use it.
We’ll switch to a fork of node-fetch with a fix. Here’s the fix: https://github.com/pnpm/node-fetch/pull/1
The logs show that you’re running pnpm 7.15, which is much too old for this issue to have been fixed. You need to upgrade to at least 7.32.2 or 8.3.1.
I’m on a mac M1, using corepack (node v20.10.0, pnpm v8.14.1) and the following rectified the issue for me
corepack prepare pnpm@latest --activate
Hope it helps someone.
The stack trace shows that you’re still using 8.1.1, and the fix for this was only introduced in 8.3.1.
See: https://github.com/mswjs/cookies/actions/runs/6798894268/job/18483965198?pr=29#step:4:18
This is because your workflow says
version: 8.10
, which YAML reads as being the same value as8.1
as it’s parsed as a number. Quoting the string, making it8.10.1
, or not setting the version in the workflow (e.g. use corepack) will all fix this.switching to node v18 LTS is working fine. Error with v20.5.0.