中文 English

Enable Version Control for Node-RED Flows

Published: 2021-08-28
Node-RED git github

Problem Description

I used to back up Node-RED flows by copying ~/.node-red/flows_xxx.json and keeping multiple versions. That was annoying, and even comparing unformatted JSON with tools like Beyond Compare was a mess.

Solution: Pretty-Print JSON

I found that by changing the setting in ~/.node-red/settings.js, the flows_xxx.json file can be saved in a pretty-printed format.

vim ~/.node-red/settings.js
# Search for flowFilePretty, find the line, and uncomment it

Solution: Enable Git Support

  1. Enable project support
vim ~/.node-red/settings.js
# Find projects: {enabled: false} and change it to enabled: true
  1. Restart Node-RED
ls -ll ~/.node-red/
# You will see a new projects/ directory
  1. Revisit the Node-RED web UI, such as 127.0.0.1:1880 Follow the prompts to create or clone a project.

  2. Sidebar information project_info_sidebar The info page above shows the current project name. project_local_changes The history page above shows the changed files under Local Changes. Click a file name to see the detailed node changes. Clicking + is equivalent to git add filename; files under Changes to commit have been added but not committed. After clicking commit, you enter a description, which is effectively git commit -m "description". project_commit_history The Commit History page shows commit history. If a remote repository is configured, you can also see how many commits the local branch is ahead of the remote, and you can push or pull here.

Reference

https://mokusolo.github.io/2019/08/22/node-red%E4%BB%A3%E7%A0%81%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/