Node-RED can be used on all platforms that can run Node.js. In this tutorial, we’ll see how to install Node-RED on macOS or a Windows PC under Windows 10. There are several installation methods. To write this tutorial, I have remained faithful to the official installation methods. The Mac installation was done on macOS El Captain (10.11.6). Installation on a higher version should not be any different.
Install node.js for macOS or Windows
Node-RED supports node.js 0.10.x or later. It is recommended to use the LTS (long-term maintenance) version of node.js
Get and install node.js 4.x LTS that matches your platform
- Max OS X: Universal
- Windows: 32-bit or 64-bit
All other versions of node.js are available here https://nodejs.org/en/download/package-manager/
Run the executable to start the installation.
The operation is very fast. The installation program will ask you the destination directories at the end of the operation.
Install Node-RED on macOS
On macOS, the installation of Node-RED is identical to Linux (or Raspian). You must precede the npm command of a sudo. The -g means that the sources will be uploaded to the npm directory and will be available for all node.js. –unsafe-perm allows to continue the installation in the event of an error.
sudo npm install -g --unsafe-perm node-red
Installation is completed
You just have to start with the node-red command. At first boot, the necessary directories and files will be created automatically
|File / folder||Localisation|
|Executable||Lien symbolique /usr/local/bin/node-red vers /usr/local/lib/node_modules/node-red/red.js|
The dot (.) In front of the directory means that it is invisible. To make it visible in the finder, open a Terminal and run the following command
defaults write com.apple.finder AppleShowAllFiles YES
Note. Run the command again with N instead of YES to hide folders and files again.
Then restart the Finder with the command
Enter the ip address of the specified server. By default it will be 127.0.0.1:1880
It’s up to you to play!
Start Node-RED on startup with PM2
There are several ways to start NR automatically on Mac (or Windows). Here I suggest you use PM2, a process manager for Node.js. The advantage is that this solution works on all platforms. Convenient, if you ever have the urge to develop on Raspberry Pi.
sudo npm install -g pm2
If you no longer know the Node-RED path, run this command
On macOS, it should be in /usr/local/bin/node-red .
To run NodeRED, run this command PM2
pm2 start /usr/local/bin/node-red -- -v
The configuration is saved and automatic start is activated
pm2 save pm2 startup
Installing Node-RED on Windows 10
There is no Terminal on Windows, but there is PowerShell that recognizes most basic Linux commands. From Cortana, enter the first Power letters to find and launch PowerShell.
Check that npm and Nodejs are properly installed. Run npm -v then node -v as on a Linux system. Everything is well installed, you can continue.
With PowerShell, we will install Node-RED as on macOS or Linux. The sudo command should not be added.
npm install -g --unsafe-perm node-red
On Windows 10, the files are installed in the directory.
Whatever your version of Windows (current or future), the installation path is indicated by npm in the installation summary (at the end of the installation).
Start Node-Red manually
To manually start NR, go to the installation directory
Then execute the command command
On first startup, you will need to add a new rule to the Windows Firewall.
So, everything works as on other platforms.
Start Node-RED automatically when Windows starts with PM2
There are several ways to start NR automatically on Windows. Here I suggest you use PM2, a process manager for Node.js. The advantage is that this solution works on all platforms. Practice, if you ever want to develop on Raspberry Pi. From PowerShell, run this command to install PM2.
npm install -g pm2
To manually start NodeRED, run this command by adapting the path to the red.js file. Change username by your name before to execute to command.
pm2 start C:\Users\<username>\AppData\Roaming\npm\node_modules\node-red\red.js -- -v
At startup, PM2 indicates the name of the application and its IDentifier and its name. Here 0 and red.
NodeRED now works in the background. Here are some useful commands. You can specify the ID or the name of the application. This is the name of the application launched by PM2 (here red).
- pm2 restart ID | NAME: restart NR.
- pm2 stop ID | NAME: stop NodeRED
- pm2 log ID | NAME: displays the real-time execution log of the indicated program. This is very useful for tracking the execution of NodeRED.
- pm2 status ID | NAME
- pm2 info ID | NAME: displays a lot of useful info (status, paths, versions …)
Now we will add the necessary packages to allow PM2 to launch automatically. run
npm install pm2-windows-startup -g pm2-startup install
All you have to do is save the configuration
At the next start, PM2 will automatically launch Node-RED at logon! After logging on, open PowerShell and run the pm2 status command to verify.
To learn more about Node-RED, see the dedicated category.
- Xiaomi Mijia Honeywell Smoke Detector Test with Domoticz, Emergency Notification with PushOver
- Test Zigbee2MQTT gateway. Part 2, include Xiaomi Aqara or Mijia accessories to Domoticz with Node-RED
- #Test Zigbee2MQTT project, hack of the Xiaomo Aqara Smart Home Gateway. Part 1: assembly, demo with Node-RED, 3D printed case [update]
- Install Node-RED on Raspbian Jessie Lite on a Raspberry Pi Zero W
- Node-RED + MQTT + ESP8266: how to drive an articulated PTZ system in WiFi
- Orange Pi: test of the OPI.GPIO package for Node-Red (node-red-contrib-opi-gpio)