服务器没有安装 git 安装先git 这个很重要
拉取源码
git clone https://github.com/node-red/node-red.git --recursive
进入源码目录
cd node-red
安装
npm install
安装node-red依赖项
如果出现 npm ERR! code 128 错误
就执行清除缓存
npm cache clean --force
如果出现 npm ERR! exited with error code: 128 错误
就执行清除缓存
git config --global url."https://".insteadOf git://
再安装
npm install
出现这个就算安装依赖成功了
77 packages are looking for funding
run `npm fund` for details
found 5 vulnerabilities (3 moderate, 2 high)
run `npm audit fix` to fix them, or `npm audit` for details
构建代码
npm run build
前台启动
npm start
关闭
Ctrl+c
生成密码
node-red admin hash-pw
Password:在这里输入密码 然后回车 zz142536
$2b$08$pguX1rCpevdb.l.hc3zi/uSyBWTf5.uVmD3AYUZcpeEazvvK3MKBK
//windows 配置文件路径
C:\Users\Administrator\.node-red\settings.js
//大概在80行的位置 去掉注释 改一下哈希 保存
//大概长这样
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2b$08$pguX1rCpevdb.l.hc3zi/uSyBWTf5.uVmD3AYUZcpeEazvvK3MKBK",
permissions: "*"
}]
},
或者直接替换为下面的配置就好
//linux命令
sudo npm install -g --unsafe-perm node-red
//或者
sudo npm install -g node-red
//windows 安装命令
npm install -g --unsafe-perm node-red
//或者
npm install -g node-red
node-red
//要关闭的话直接关掉黑窗口就好
启动后会生成配置文件 到 /Users/nol/.node-red/settings.js
具体参考官方文档 [设置文件:节点-红色 (nodered.org)](https://nodered.org/docs/user-guide/runtime/settings-file)
//windows 配置文件路径
C:\Users\Administrator\.node-red\settings.js
node-red admin hash-pw
Password:在这里输入密码 然后回车 zz142536
$2b$08$pguX1rCpevdb.l.hc3zi/uSyBWTf5.uVmD3AYUZcpeEazvvK3MKBK
$2b$08$lFndYSl80Vao26jntHLUJO5kK40bhz6u8VrV.CNNyNRQzXyIyBEZq
//windows 配置文件路径
C:\Users\Administrator\.node-red\settings.js
//大概在80行的位置 去掉注释 改一下哈希 保存
//大概长这样
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2b$08$pguX1rCpevdb.l.hc3zi/uSyBWTf5.uVmD3AYUZcpeEazvvK3MKBK",
permissions: "*"
}]
},
//pm2文档
//https://www.cnblogs.com/yalong/p/13931999.html
//启动
pm2 start node-red
//列出所有
pm2 list
//关闭所有
pm2 kill
//关闭
pm2 stop node-red
配置地址
/root/.node-red
程序地址
/usr/local/lib/node_modules/node-red
后台启动追加日记:
forever start -l forever.log -o out.log -e err.log -a /usr/local/lib/node_modules/node-red/red.js
"关闭后台": "
forever stop /usr/local/lib/node_modules/node-red/red.js
settings.js
大概在77行
/** To password protect the Node-RED editor and admin API, the following
* property can be used. See http://nodered.org/docs/security.html for details.
* zz142536
*/
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2b$08$lFndYSl80Vao26jntHLUJO5kK40bhz6u8VrV.CNNyNRQzXyIyBEZq",
permissions: "*"
}],
sessionExpiryTime: 86400,
default: {
permissions: "read"
}
},
//进入目录
cd E:\aa\nodered\node-red
//前台启动
npm start
//pm2文档
//https://www.cnblogs.com/yalong/p/13931999.html
//启动
pm2 start packages/node_modules/node-red/red.js
//列出所有
pm2 list
//关闭所有
pm2 kill
//关闭
pm2 stop node-red