Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is it so hard to use bpmn-js in a NodeJS TS project ? #2138

Closed
younes-io opened this issue Apr 11, 2024 · 1 comment
Closed

Why is it so hard to use bpmn-js in a NodeJS TS project ? #2138

younes-io opened this issue Apr 11, 2024 · 1 comment
Labels
question Further information is requested

Comments

@younes-io
Copy link

younes-io commented Apr 11, 2024

Can someone please help. I can't find any documentation about this.

// tsconfig.json
{
  "compilerOptions": {
    "skipLibCheck": true,
    "target": "es2022",
    "module": "Node16",
    "lib": ["ES2022", "DOM"],
    "moduleResolution": "node16",
    "rootDir": ".",
    "outDir": "build",
    "allowSyntheticDefaultImports": true,
    "importHelpers": true,
    "alwaysStrict": true,
    "sourceMap": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitAny": false,
    "noImplicitThis": false,
    "strictNullChecks": false
  },
  "include": ["src/**/*", "__tests__/**/*"],
  "exclude": ["node_modules/**/*"]
}

My code throws this:

> node-typescript-boilerplate@0.0.0 lint
> eslint . --ext .ts --ext .mts


/workspaces/node-typescript-boilerplate/src/main.ts
   6:1  warning  Missing return type on function  @typescript-eslint/explicit-function-return-type
  19:1  warning  Missing return type on function  @typescript-eslint/explicit-function-return-type
  29:1  warning  Missing return type on function  @typescript-eslint/explicit-function-return-type

✖ 3 problems (0 errors, 3 warnings)

$ tsc -p tsconfig.json
Done in 2.67s.
yarn run v1.22.19
$ node build/src/main.js
/workspaces/node-typescript-boilerplate/node_modules/bpmn-js/lib/Modeler.js:1
import inherits from 'inherits-browser';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:128:18)
    at wrapSafe (node:internal/modules/cjs/loader:1280:20)
    at Module._compile (node:internal/modules/cjs/loader:1332:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/workspaces/node-typescript-boilerplate/build/src/main.js:4:43)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)

Node.js v20.12.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
node ➜ /workspaces/node-typescript-boilerplate (main) $ 

BTW

import BpmnJS from 'bpmn-js/lib/Modeler';
const bpmnJS = new BpmnJS();
@younes-io younes-io added the bug Something isn't working label Apr 11, 2024
@nikku
Copy link
Member

nikku commented Apr 11, 2024

What would you like to accomplish? Looks like you want to use bpmn-js in a NodeJS project?

From your logs I see:

  • The code validates (eslint) correctly
  • The code builds (tsc) correctly
  • The code fails to execute in NODE. This is intentional. It is a browser-based library.

@nikku nikku closed this as completed Apr 11, 2024
@nikku nikku added question Further information is requested and removed bug Something isn't working labels Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

2 participants