1

我已将gotNPM 模块安装到我的项目中,但现在它引起了问题。

它说要删除type:module,但我不能这样做,因为它是 NPM 模块而不是我的。

我该如何解决这个问题?

这是一个使用 NestJS 生成的新项目,其中没有其他可能导致问题的项目。

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\src\faastracker-api\node_modules\got\dist\source\index.js
require() of ES modules is not supported.
require() of C:\src\faastracker-api\node_modules\got\dist\source\index.js from C:\src\faastracker-api\dist\scraping-bee\scraping-bee.service.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\src\faastracker-api\node_modules\got\package.json.
4

0 回答 0