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 -vprints: v20.0.0- Windows, macOS, or Linux?: Linux
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 66
- Comments: 82 (26 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 4 years ago
- :green_heart: Set `node-version` to 19 See https://github.com/pnpm/pnpm/issues/6424 — committed to neutron0831/nlp100-ts by neutron0831 4 years ago
- fix(publish): 💚 specify node version https://github.com/pnpm/pnpm/issues/6424 — committed to importantimport/a2 by kwaa 4 years ago
- fix: should work with node.js 20 ref pnpm/pnpm#6424 — committed to pnpm/node-fetch by zkochan 4 years ago
- fix: should work with node.js 20 (#1) ref pnpm/pnpm#6424 — committed to pnpm/node-fetch by zkochan 4 years 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 nickserv/arktype by nickserv 4 years 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 4 years 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 4 years 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 4 years 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 4 years 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 3 years 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 3 years 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 3 years 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 3 years 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 3 years 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 4 years 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 nickserv 3 years ago
- chore(deps): update pnpm to v8.5.0 (#2063) Resolves https://github.com/pnpm/pnpm/issues/6424 — committed to phantomeco/i18n by dargmuesli 4 years 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/turborepo by chris-olszewski 3 years 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 3 years ago
To help anyone else using pnpm globally installed by pnpm:
Updating
pnpm/action-setuptov4solved the issue for me ✅Seeing this in a CLI environment after zero changes between yesterday and today.
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 --activatedid 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:
I was able to fix this by bumping the action and the pnpm version
Still happening, with pnpm v8.15.3 and node v20.11.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_THISas well as:ERR_PNPM_META_FETCH_FAIL GET https://registry.npmjs.org/packagename: Value of "this" must be of type URLSearchParamsStill happening for me with pnpm v8.14.0 and node v20.10.0
I’m also facing this issue.
Restarting terminal fixed the issue
Still happen with pnpm 9.0.6 and node v20.11.1
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.
Updating
pnpm/action-setuptov4worked for me as well.This should definitely not be closed
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.
To me a newer version of pnpm helped. I had to install it using
npm install -g pnpm --forceif 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!Would love to know how this is suddenly happening for so many people.
You can use
corepack upto update your pnpm version andpackageManagerinpackage.jsonin one step.Very strange… in my case nothing worked for me until I used:
yarn global add pnpm@latestwhy don’t you use native ‘fetch’? So wouldn’t you be avoiding problems like this in the future?
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’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@latestshould do the trick. Or just installnpm i -g pnpm@latestdirectly.@Johnnasimba
there is a solution literally one comment before yours.
I’m facing the same issue, has anyone found a solution yet
I get it when using
pnpm installon 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.
My problem was that I was using the pnpm provided via homebrew.
Check via:
If it is
/opt/homebrew/bin/pnpmuninstall viabrew uninstall pnpmand install vianpx pnpm i -g pnpm@latestFWIW, as a first time user of
pnpm, I experienced this issue and believe it’s still an unfixed bug.I followed a link to the pnpm installation page to install
pnpm. The first few lines of the installation page do not make it clear that using the standalone script is the preferred way to installpnpm. I read those lines as saying that I “could” use the standalone script if I’m on an older version of Node.js, however, I can use native Node.js features likecorepackornpmto installpnpm.I choose to use
corepacksince all I had to do was this:Then I run
pnpm iin the project that I’m attempting to set up and I get theERR_INVALID_THISover and over.I find this issue and check my
pnpmversion and see thatcorepackhas installed an old version by default, so I followed instructions to update the version. After updating the version ofpnpm, I continued to get the sameERR_INVALID_THIS. I switched tonode v18.18.0and the issue went away.I switched back to
node v21.6.0, “disabled” pnpm by runningcorepack disable pnpm, then installedpnpmusing the standalone script.Since at one point, I used corepack to update pnpm to the latest, and that didn’t work, I consider this to still be a bug.
Of course, now that I got to a point where
pnpm iworks, I’m running into another issue that I believe may be a core Node.js issue detecting the cpu arch sincepnpmseems to have installed the correct optional dependency (@rollup/rollup-darwin-arm64), but the library (rollup) thinks it should be@rollup/rollup-darwin-x64./edit: I figured out my issue in case anyone is interested… I had installed node via
nvmwhen I was running in aniTermsession that had been opened using Rosetta to emulate an x64 on the Apple arm chips. After re-installing node, in a session opened without Rosetta, node reportsarm64, which allowsrollupto resolve the correct dependency.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 --activateHope 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.1as 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.