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

推荐订阅源

GbyAI
GbyAI
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
L
LangChain Blog
F
Fortinet All Blogs
C
Check Point Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
J
Java Code Geeks
月光博客
月光博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
宝玉的分享
宝玉的分享
Jina AI
Jina AI

轶哥博客

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中得到修复,升级后就能解决该问题。