服务端渲染示例在最新node下报错 #6592
Mleijian posted onGitHub
我使用文档的示例运行错误,我对前端接触不多,修正一下文档或bug var d3 = require('d3-color'); ^
Error [ERR_REQUIRE_ESM]: require() of ES Module E:\test\node_modules\d3-color\src\index.js from E:\test\node_modules@antv\g-lite\dist\index.js not supported. Instead change the require of E:\test\node_modules\d3-color\src\index.js in E:\test\node_modules@antv\g-lite\dist\index.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (E:\test\node_modules@antv\g-lite\dist\index.js:24:10) { code: 'ERR_REQUIRE_ESM' }
Node.js v20.12.0
我修改require未import后,依然不行 const chart = new Chart({ ^
ReferenceError: Chart is not defined at Object.<anonymous> (E:\test\index.js:46:15) at Module._compile (node:internal/modules/cjs/loader:1369:14) at Module._extensions..js (node:internal/modules/cjs/loader:1427:10) at Module.load (node:internal/modules/cjs/loader:1206:32) at Module._load (node:internal/modules/cjs/loader:1022:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49