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 |
---|---|
Modules | /usr/local/lib/node_modules |
User Directory | /Users/<user>/.node-red |
Settings File | /Users/<user>/.node-red/settings.js |
Flows File | /Users/<user>/.node-red/flows_<hostname>.json |
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
killall Finder
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
which node-red
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.
c:\\Users\<username>\AppData\Roaming\npm\node_modules
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
cd C:\Users\<username>\AppData\Roaming\npm\node_modules\node-red
Then execute the command command
node red.js
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
pm2 save
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)
now thats a stupid tutorial, it should be about how to install on macOS or Windows and just when the important stuff should happen you only explain macOS and Linux leaving the whole windows explanation to as little as “how to download th software”
Hello Thomas . You are right, this article can not be anything now. But you’re a little rough with me! First of all, do not forget that Node-red remains a very recent open source project that evolves constantly and very quickly. The installation methods evolve … So I have to constantly update the articles or write new ones. I do all that work on my spare time. I hope with all my heart that you love the rest of the site and that you have found my other articles more useful. See you soon. Christophe
i may have gotten a little carried away here out of frustration of not finding anything about the windows installation that goes beyond download this file and install as this is not the whole story to tell.
For some reason everyone is always only mentioning Linux which is already explained in detail but there is nothing on how to do it under windows or any kind of troubleshooting under windows.
I understand Thomas. It is true that today Raspberry monopolizes the DIY market to the detriment of Windows. I suggest you leave me a little time. I will install it on my windows 10 and if you want we will look together if you encounter difficulties 😉
got it working now, turns out all you need is one line to enter into cmd and it works.
too bad nobody simply lists the line and tells you to do it.
here is how it works.
Great. I just finished rewriting the article. I hope you find other useful information. Christophe
looks good and good to know how to auto run node red easily, thanks.
now lets increase the difficulty a little and explain me how to do the same on an esp8266 (ESP01 model) 😀
Thank you very much. Ah ah. Can be this :
– ESP-01: Reinstalling the Original NodeMCU Firmware (ESP8266) : https://diyprojects.io/esp-01-reinstalling-original-firmware-esp8266/
– Connect an I2C SSD1306 OLED display and an ESP-01 (ESP8266) : https://diyprojects.io/connect-i2c-ssd1306-oled-display-esp-01-esp8266/
But clearly, I prefer the esp12 as the one that equips the wemos d1 mini https://diyprojects.io/esp8266/esp8266-wemos-d1-mini/
That’s enough 😀
yea the esp12 is something i will get in the future, just bought the esp01 to tinker around when i just started and only recently managed to program it at all.
what i am not sure about is when i flash nodemcu back on it what exactly is it going to do?
my end goal is that i can either access node red directly on the esp8266 via a webserver running on it.
or (i am not sure if this is even possible) have some kind of client running on the esp and use my local node red which should depoy to the esp client.
is anything like this even possible?
I find ESP12 easier to program, especially with simple arduino code. Normally when you flash nodemcu, you find the identical card at the time of purchase. For web server programming, you should find what you need in this category https://diyprojects.io/esp8266/esp8266-interface-html-server-web/#.WVH0VhOLR24 and this https://diyprojects.io/esp8266/communication-client-web-esp8266/#.WVH0bxOLR24. I still have to do the article on storing parameters in the eeprom.
Yes you can easily drive to esp8266 directly with HTTP requests. But even easier, it’s MQTT with Node-RED or a home automation server (some examples https://diyprojects.io/?s=mqtt+node-red). It’s an industry standard now. If you need advice for your project do not hesitate to contact me. See you soon. Christophe
Hi just to say thanks for the tutorial. I followed it and now have Node-red running on my Mac.