【发布时间】:2022-09-25 19:33:14
【问题描述】:
我正在使用 \'got\' 版本 \'11.8.3\' 并且出现以下错误。
/app/node_modules/got/dist/source/core/index.js:696 throw new TypeError(\'The payload has been already provided\'); ^ TypeError: The payload has been already provided at Request.onLockedWrite (/app/node_modules/got/dist/source/core/index.js:696:19) at PassThrough. (node:internal/streams/pipeline:323:31)
因此,我尝试将 \'got\' 升级到最新版本 (12.0.3)。但在此之后我得到以下错误:
/app/server/lib/my-api.js:8 const got_1 = __importDefault(require(\"got\")); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/got/dist/source/index.js from /app/server/lib/my-api.js not supported. Instead change the require of index.js in /app/server/lib/my-api.js to a dynamic import() which is available in all CommonJS modules.
但是,我在我的 .ts 文件中使用了这个语句。
import got from \'got\'
你能建议消除这些错误吗
-
您的 TypeScript 设置正在将
import转换为require并且got包与它不兼容 -
在那种情况下,有什么办法可以消除得到\'11.8.3\'版本(\'有效载荷已经提供\')带来的第一个错误
标签: javascript node.js typescript npm dependencies