Warning: file_put_contents(/home/clients/81b51a55b78a35c5c4c50dd82cac1015/diyprojects/wp-content/uploads/wpo/images/wpo_logo_small.png.webp): failed to open stream: Disk quota exceeded in /home/clients/81b51a55b78a35c5c4c50dd82cac1015/diyprojects/wp-content/plugins/wp-optimize/vendor/rosell-dk/webp-convert/src/Convert/Converters/Gd.php on line 428
Installing Node-RED on macOS or Windows, auto startup with PM2 • DIY Projects
DIY Projects

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

macos node-red installation chrome

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

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

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.


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

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.


Click to rate this post!
[Total: 1 Average: 5]
Exit mobile version