提问人:Behdad Nemati 提问时间:6/25/2023 更新时间:6/25/2023 访问量:23
无法使用 node 编译 camunda 调制器的 JsWorker
cannot compile JsWorker for camunda modulator using node
问:
我正在尝试为 Camunda Modulator 部署一个 jsworker,但是当我使用 node 编译我的 js 文件时,出现以下错误:
$ nodejs ./CheckRequestFeasibilityWorker.js
(node:27539) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `nodejs --trace-warnings ...` to show where the warning was created)
/JsWorkers/CheckRequestFeasibilityWorker/CheckRequestFeasibilityWorker.js:1
import { Client, logger } from "camunda-external-task-client-js";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Node.js v18.15.0
我已经使用 npm 安装了该软件包camunda-external-task-client-js
这是我的代码:
import { Client, logger } from "camunda-external-task-client-js";
// configuration for the Client:
// - 'baseUrl': url to the Process Engine
// - 'logger': utility to automatically log important events
const config = { baseUrl: "http://localhost:8080/engine-rest", use: logger };
// create a Client instance with custom configuration
const client = new Client(config);
// susbscribe to the topic: 'check-request-feasibility'
client.subscribe("check-request-feasibility", async function({ task, taskService }) {
// Put your business logic
var Is_feasible = math.random() >= 0.5;
const processVariables = new Variables();
processVariables.set("Is_feasible",Is_feasible);
// complete the task
await taskService.complete(task);
});
答: 暂无答案
评论