chartiq in nestjs Must use import to load ES Module

Viewed 334

I'm trying to use chartiq study calculator in NestJs and it throws the following error:

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.

how can I fix this? I'm only trying to import it and App keep throw this exception

0 Answers
Related