Notes on Node-RED development on a Raspberry Pi using Visual Studio Code
In the past, I developed Node-RED nodes by locally editing using Visual Studio Code and exporting the directory via NFS to a Raspberry Pi with the appropriate hardware installed, and the node was added to Node-RED via symlinks. It worked, but it was brittle and there can be permissions issues and its annoying if the Pi reboots and cannot connect to the fileserver then flows will not start because the nodes are not present, it's just so tedious.
My new, improved development environment involves VSC's "remote-ssh" extension.
As always, detailed notes make it easier to set things up. There are so many small details from configuring git on the RaspPi to removing the "nano" editor to make it easier to do command line git commits.
So, here are my cut and paste notes that start with a newly installed RaspPi (or rephrased, OS and Node-RED previously installed) and end with a working VSC development environment for Node-RED:
On Desktop:
Install Visual Studio Code extension “Remote - SSH”
https://code.visualstudio.com/docs/remote/ssh
https://code.visualstudio.com/docs/remote/linux
https://code.visualstudio.com/docs/remote/troubleshooting#_installing-a-supported-ssh-client
https://code.visualstudio.com/docs/remote/troubleshooting#_improving-security-on-multi-user-servers
Install Windows OpenSSH client
Move SSH keys around for key-based SSH authentication
On New Remote:
On windows scp the key from the windows host to the new remote
scp c:\users\vince\.ssh\id_rsa.pub pi@new_remote:
then while logged into the new remote run:
cat id_rsa.pub >> .ssh/authorized_keys
Then test a login from windows to the new remote
ssh pi@new_remote
Create a SSH key on the new remote and add the .ssh/id_rsa.pub to GitLab
ssh-keygen, then add the key to GitLab
Prepare git on the new remote
On the new remote:
sudo apt-get install git
sudo dpkg –purge nano
git config –global user.email “vince.mulhollon@springcitysolutions.com”
git config –global user.name “Vince Mulhollon”
Install the git repo for the project on the remote
git clone the applicable Node-RED node project into ~ directory
Add git repo to installed Node-RED
cd ~/.node-red
npm install ~/node_git_repo_from_above
Restart node-red
./node-red-restart
Install standard.js in a project
npm install standard –save-dev
Then run it with “npx standard”.
Install standard.js extension in VS Code
“View” “Extensions”
Search for vscode-standard
Click install
Remember to install the standard engine as a devDependencies and it works automatically.
Anyway I hope these detailed notes help somebody do remote Node-RED development on a Raspberry Pi using Visual Studio Code.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.