嵌入现有应用
https://nodered.org/docs/user-guide/runtime/embedding
所以当去管理调色板并安装任何新节点时,我在编辑器
中看到错误安装失败:node-red-contrib-ui-svg
无法找到模块的node-red-contrib-ui-svg
查看日志获取更多信息
和这个完整的日志:
2021-03-07T10:26:01.901Z Install : node-red-contrib-ui-svg 2.2.1
2021-03-07T10:26:01.910Z npm.cmd install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production node-red-contrib-ui-svg@2.2.1
2021-03-07T10:26:10.448Z [err] npm notice
2021-03-07T10:26:10.449Z [err] created a lockfile as package-lock.json. You should commit this file.
2021-03-07T10:26:10.450Z [out] + node-red-contrib-ui-svg@2.2.1
2021-03-07T10:26:10.450Z [out] added 29 packages from 28 contributors in 6.044s
2021-03-07T10:26:10.488Z rc=0
但是在编辑器中检查新安装的节点时不能显示其。重启节点红后,同样的问题这是我的nodejs应用:
var http = require('http');
var express = require("express");
var RED = require("node-red");
// Create an Express app
var app = express();
// Add a simple route for static content served from 'public'
app.use("/", express.static("public"));
// Create a server
var server = http.createServer(app);
// Create the settings object - see default settings.js file for other options
var settings = {
httpAdminRoot: "/red1",
httpNodeRoot: "/api",
userDir: "./hhh",
functionGlobalContext: {} // enables global context
};
// Initialise the runtime with a server and settings
RED.init(server, settings);
// Serve the editor UI from /red
app.use(settings.httpAdminRoot, RED.httpAdmin);
// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode);
server.listen(8005);
// Start the runtime
RED.start();
node-red : v1.2.9-git
npm -v : 6.14.4
node -v : v12.16.3
感谢hardill它解决了
请运行以下2个测试:使用设置对象中userDir的完整路径:D:Projectnode-red-template embeddedhhh