node.js - nestjs 中的 chartiq 必须使用 import 来加载 ES Module
问题描述
我正在尝试在 NestJs 中使用 chartiq 学习计算器,它会引发以下错误:
internal/modules/cjs/loader.js:1092
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: A:\projects\chartiq-service\chartiq-service\node_modules\chartiq\modules\studycalc\study-calculator.js
require() of ES modules is not supported.
require() of A:\projects\chartiq-service\chartiq-service\node_modules\chartiq\modules\studycalc\study-calculator.js from A:\projects\chartiq-service\chartiq-service\dist\chartiq\services\chartiq.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 study-calculator.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from A:\projects\chartiq-service\chartiq-service\node_modules\chartiq\package.json.
我怎样才能解决这个问题?我只是想导入它,App 不断抛出这个异常
解决方案
推荐阅读
- c# - UIAutomation 元素为远程桌面连接上的边界矩形返回错误值
- c# - SharePoint 客户端 ID 和密钥续订不起作用
- php - 单击链接后关闭移动菜单
- google-cloud-platform - 在 GCP 中为项目设置共享服务
- ios - 免费试用期后应用内购买一次性付款
- python - python pyserial 无法在 COM 端口建立与硬件的连接
- python - BadZipFile 仅在我使用变量时出错
- python - TensorFlow 的 QAT 似乎没有使用 AllValuesQuantizer 执行每通道量化
- firebase - 如何在 Firebase 中使用相同的电子邮件创建两个帐户
- c# - 如何在 C# 中快速搜索 word 和 Pdf 文档上的特定文本?