我正在使用 typescript、oclif 和 d3.js 等开发一个节点项目。Typescript 是在使用ocif创建项目时由 npx 配置的,因此我无法控制它的所有方面(特别是关于 TS,我不是专家。TS 很棒,但配置方面,嗯)。
不管怎样,一切都工作正常,但我最近添加了 d3 作为依赖项并尝试构建文档,但在运行它时出现此错误:
(node:22554) [ERR_REQUIRE_ESM] Error Plugin: dbacl [ERR_REQUIRE_ESM]: require() of ES Module /dbacl/node_modules/d3/src/index.js from /dbacl/src/tree/graph-tree.ts not supported.
Instead change the require of index.js in /Users/nico/Furo/Dev/dbacl/src/tree/graph-tree.ts to a dynamic import() which is available in all CommonJS modules.
Run Code Online (Sandbox Code Playgroud)
在我使用 d3 的文件中,我按照文档导入它:
(node:22554) [ERR_REQUIRE_ESM] Error Plugin: dbacl [ERR_REQUIRE_ESM]: require() of ES Module /dbacl/node_modules/d3/src/index.js from /dbacl/src/tree/graph-tree.ts not supported.
Instead change the require of index.js in /Users/nico/Furo/Dev/dbacl/src/tree/graph-tree.ts to a dynamic …
Run Code Online (Sandbox Code Playgroud)