How to Install Node-RED on Ubuntu Server
In this tutorial, we will show you how to install Node-RED on Ubuntu Server. Node-RED is a visual programming tool used for wiring together hardware devices, APIs, and services. It is an open-source project that runs on Node.js.
Prerequisites
- Ubuntu Server 18.04 or Later
- A non-root user with sudo privileges
- Node.js v12.x.x or Later
Step 1: Install Node.js on Ubuntu
First, we need to install Node.js on Ubuntu Server. Node.js is a runtime environment for executing JavaScript code outside of a web browser. Node.js is available in Ubuntu's default repositories, but those versions are often outdated. We recommend adding the NodeSource package repository to your system to ensure that you get the latest version of Node.js.
Run the following commands to add the NodeSource package repository to your Ubuntu Server:
sudo apt update -y
sudo apt upgrade -y
sudo apt install curl -y
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
After running the above command, install Node.js as shown below:
sudo apt-get install nodejs
Step 2: Install Node-RED
Once Node.js is installed, we can now proceed to install Node-RED on Ubuntu Server. We will use the Node-RED script provided by the Node-RED team. The script will download and install all the necessary packages and dependencies for Node-RED.
Run the following command to download and run the Node-RED script:
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
The script will take several minutes to complete, and it will install Node-RED and its dependencies.
Step 3: Start Node-RED
Once Node-RED is installed, we can start the service by typing the following command:
sudo systemctl start nodered.service
By default, Node-RED will start on port 1880. Open your web browser and navigate to http://your-server-ip:1880/ to access the Node-RED editor.
Step 4: Enable Node-RED to Start on Bootup
To enable Node-RED to start on bootup, run the following command:
sudo systemctl enable nodered.service
Step 5: Stop Node-RED
To stop Node-RED, type the following command:
sudo systemctl stop nodered.service
Conclusion
You have now successfully installed Node-RED on Ubuntu Server. Node-RED is a powerful tool that can help you quickly develop and deploy applications that integrate with hardware devices, web APIs, and other services.