惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
罗磊的独立博客
IT之家
IT之家
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
博客园 - Franky
博客园 - 聂微东
博客园_首页
爱范儿
爱范儿
量子位
博客园 - 三生石上(FineUI控件)
G
Google Developers Blog
Martin Fowler
Martin Fowler
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Y
Y Combinator Blog
Vercel News
Vercel News
腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
Engineering at Meta
Engineering at Meta

轶哥博客

blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog
blog
2023-05-04 · via 轶哥博客

在Node.js 20版本中,你可能会遇到如下异常:

 WARN  GET https://registry.npmjs.org/chatgpt/-/chatgpt-5.0.10.tgz error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.

为了解决这个问题,你只需要升级到pnpm v8.3.1或更高版本。可以通过以下命令安装并激活指定版本的pnpm:

corepack prepare pnpm@8.3.1 --activate

问题原因及修复

这个问题的根本原因在于pnpm模块依赖的node-fetch库中,URLSearchParams.prototype[p].call()函数调用时,错误地把this上下文设置为了receiver(代理对象)而非target(原始对象)。将this上下文设置为receiver导致URLSearchParams的方法无法正确访问原始对象的属性和方法,进而抛出ERR_INVALID_THIS异常。

通过将this上下文正确地设置为target(原始对象),URLSearchParams的方法可以正确访问原始对象的属性和方法,从而解决了ERR_INVALID_THIS异常。

如果你在使用Node.js 20时遇到了pnpm的ERR_INVALID_THIS异常,请升级到pnpm v8.3.1或更高版本。这个问题已经在新版pnpm中得到修复,升级后就能解决该问题。