Use bpmn-js with Node.js's native ES6 Support

Hi there,

the current Node.js Version supports ES6 Modules natively.
All issues I found in this forum deal with bundlers as workaround.

Shouldn’t I be able to import and use bpmn-js directly within a Node.js v14.x.x application, without the detour of bundlers?

Assuming a minimal project setup as follows:

package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "node index.js"
  },
  "devDependencies": {},
  "dependencies": {
    "bpmn-js": "8.2.0"
  },
  "author": "",
  "license": "ISC"
}

index.js

import BpmnViewer from 'bpmn-js';

export default (str) => {
    return str.toUpperCase();
};

Place the two files within a folder and run npm install and npm run start and you should recognize the following error:
I still get the follwing error:

\node_modules\bpmn-js\index.js:1
export {
^^^^^^

SyntaxError: Unexpected token 'export'

Can somebody tell me how to adapt my code to get it running?

Thanks!

Why do you want to use bpmn-js outside of the browser? Mind that it uses Web APIs.

1 Like

Yeah you’re right, seems like I assumed a wrong purpose of the library (or my application?).
I am still a little bit confused, but that is not a bpmn-js related issue.

However, I think I want to use the bpmn-moddle library, and it works quite fine with this one.

Thanks for your replies.

1 Like