"import" and "require"

  • Hi,

    I am trying to use d3 as a library in a script for an XLSX recipe report.

    Using require('d3') like with other libraries results in this error:
    Unable to require module d3. require() of ES Module ... [filepath]/workerHandler.js not supported.
    Instead change the require of index.js in ... [filepath]workerHandler.js to a dynamic import() which is available in all CommonJS modules.

    If I change it to import * as d3 from 'd3' i get this error:

    0_1661410888869_Screen Shot 2022-08-25 at 5.00.48 pm.png

    Any advice?


  • Just FYI I got around this issue by creating a asset js file and just importing that as an asset into the script. So it is not urgent.

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.