Installing Node-RED on macOS or Windows, auto startup with PM2

Black Friday on Amazon right now! Black friday Banggood Gearbest Black Friday
Extra 10% off For XIAOMI SUPER HOME TECH GADGET Sale

Smart Home kits, security camera, robot vacuum cleaner, air purifier ... *Excluding products already on promotion

Reveal
35 days left

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

macos node-red installation node.js autre plateformes

Run the executable to start the installation.

macos node-red installation node.js

The operation is very fast. The installation program will ask you the destination directories at the end of the operation.

macos node-red installation node.js repertoires

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.

Installation is completed

macos node-red npm install -g --unsafe-perm

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

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

macos node-red demarrage

It’s up to you to play!

macos node-red installation chrome

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.

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

The configuration is saved and automatic start is activated

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.

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.

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.

At startup, PM2 indicates the name of the application and its IDentifier and its name. Here 0 and red.

 pm2 start node-red windows

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 …)

pm2 info node-red windows10

Now we will add the necessary packages to allow PM2 to launch automatically. run

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.

 pm2 startup status windows 10 node-red nodered

To learn more about Node-RED, see the dedicated category.

 

Subscribe to the weekly newsletter

No spam and no other use will be made of your email. You can unsubscribe anytime.

  • Thomas Winnerl

    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

      • Thomas Winnerl

        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 😉

          • Thomas Winnerl

            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

          • Thomas Winnerl

            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 😀

          • Thomas Winnerl

            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

DIY Projects