---
tags: notes, RT_blog, node red, node.js
---
# Node-Red: Getting Started
[Node-Red Official Page](https://nodered.org/)
[Node-Red Github Page](https://github.com/node-red)
## Install node-red
- Pre-Requisites: `node.js 10.x` and `npm`:
First thing first:
```
sudo apt update
```
`curl` is a quite common tool for http requests and download files via url. In case you need it:
```
sudo apt install curl
```
Download and execute the Node.js 10.x installer. This command leave nothing in the current folder. You don't have to delete anything after this command executed.
```
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
```
After the installer executed, you will have to install nodejs and npm with apt-get:
```
sudo apt-get install -y nodejs
```
Check if the command works:
```
nodejs -v
npm -v
```
### Install `node-red` with `npm` (Recommanded)
The option `-g` is for globally install and you can check what is `--unsafe-perm` for [here](https://stackoverflow.com/questions/49084929/npm-sudo-global-installation-unsafe-perm).
```
sudo npm install -g --unsafe-perm node-red
```
### Install `node-red` with `snap`
Note that `snap` might not be pre-installed in your OS distribution.
```
sudo snap install node-red
```
A package installed with `snap` will execute in a sandbox(container) with restricted access to the host OS for security concerns. The restricted privilege is configurable.
### Install and run `node-red` with `docker`
```bash
sudo docker run -it -p 1880:1880 --name mynodered nodered/node-red
```
Port option: `-p host_port:container_port`
For more details see the official [node-red docker guide](https://nodered.org/docs/getting-started/docker).
## Run `node-red`
Use the command `node-red` to start and hit `ctrl+c` to stop.
```bash
~$ node-red
3 Sep 06:28:06 - [info]
Welcome to Node-RED
===================
3 Sep 06:28:06 - [info] Node-RED version: v1.1.3
3 Sep 06:28:06 - [info] Node.js version: v10.22.0
3 Sep 06:28:06 - [info] Linux 4.15.0-115-generic x64 LE
3 Sep 06:28:06 - [info] Loading palette nodes
3 Sep 06:28:07 - [info] Settings file : /root/.node-red/settings.js
3 Sep 06:28:07 - [info] Context store : 'default' [module=memory]
3 Sep 06:28:07 - [info] User directory : /root/.node-red
3 Sep 06:28:07 - [warn] Projects disabled : editorTheme.projects.enabled=false
3 Sep 06:28:07 - [info] Flows file : /root/.node-red/flows_nadi-node-red.json
3 Sep 06:28:07 - [info] Creating new flow file
3 Sep 06:28:07 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
3 Sep 06:28:07 - [info] Starting flows
3 Sep 06:28:07 - [info] Started flows
3 Sep 06:28:07 - [info] Server now running at http://127.0.0.1:1880/
```
Node-Red will execute as a web sever. Default port: 1880.
Go `http://localhost:1880` with browser to enter the Node-Red editor page. Replace `localhost` with IP address if Node-Red is running on an other machine. You should see a dynamic web page:

If port 1880 is already taken on your machine, you can specify different port number by:
```bash
node-red --port=8080
```
## Deploy your first flow
Onece you have entered nod-red editor page, you can edit and deploy a flow.
1. From the left sidebar, select `common`=>drag `inject` node to the edit zone
2. From the left sidebar, select `common`=>drag `debug` node to the edit zone
3. Wire them up

4. Click `Deploy` at the right-top conner. A little blue dot on a node stands for undeploied change.
5. Click the inject button and you should see a timestamp in the debug console from the right sidebar.


This means everything is configured probally. You can start you journey with `node-red`