Problems Importing BpmnModeler and CliModule in Backend

Hello everyone,
I am still quite a newbie in using BPMNjs. After we integrated the BPMN-Modeler in our project, I now want to use the CLI in the backend. I have tried to install this with npm i bpmn-js-cli (and also with npm install from my package.json) and then import it using const CliModule = require('bpmn-js-cli');

Unfortunately I always get the following error without even addressing the module in the code.

20:16:31 web.1   |  export {
20:16:31 web.1   |  ^^^^^^
20:16:31 web.1   |  SyntaxError: Unexpected token 'export'
20:16:31 web.1   |      at wrapSafe (node:internal/modules/cjs/loader:999:16)

Is there any way to install the CLI and Modeler using require?


Hi @lukashueller , welcome!

bpmn-js-cli exposes ES modules. You have to use a bundler such as Webpack or Rollup to bundle it for the browser. We also have a bundling example for bpmn-js you can check out.

Please keep in mind that our libraries are not headless but usually require a DOM of some sort. Depending on your use-case you’d need to mock it or use something else.