配置Node-Red
cli 启动 node-red 需要有一个配置文件,如果没有 node-red 会帮你创建一个 setting.js。
通过 API 启动 node-red 需要传入 setting 对象,与 setting.js 的内容相同,选项见 https://nodered.org/docs/user-guide/runtime/configuration。
其中
flowFile: "flows.json", // 固定文件的名字
flowFilePretty: true, // 格式化输出文件,便于 git 合并
functionGlobalContext: {
// 可以传入需要使用的工具库,通过 global context 获取
libs: {
dateFns: require("date-fns"),
lodash: require("lodash"),
moment: require("moment"),
fetch: require("node-fetch"),
ramda: require("ramda"),
rxjs: require("rxjs"),
rxops: require("rxjs/operators"),
json5: require("json5"),
},
},
Last updated
Was this helpful?