Running Node-RED locally on your Computer

Introduction to Node-RED Getting started with Node-RED
18 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.28
List Price:  €96.12
You save:  €28.84
£55.93
List Price:  £79.91
You save:  £23.97
CA$98.01
List Price:  CA$140.02
You save:  CA$42.01
A$107.87
List Price:  A$154.11
You save:  A$46.23
S$94.42
List Price:  S$134.90
You save:  S$40.47
HK$544.78
List Price:  HK$778.29
You save:  HK$233.51
CHF 62.22
List Price:  CHF 88.89
You save:  CHF 26.67
NOK kr779.46
List Price:  NOK kr1,113.56
You save:  NOK kr334.10
DKK kr501.79
List Price:  DKK kr716.88
You save:  DKK kr215.08
NZ$119.98
List Price:  NZ$171.41
You save:  NZ$51.43
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.18
৳8,402.58
List Price:  ৳12,004.20
You save:  ৳3,601.62
₹5,911.93
List Price:  ₹8,445.97
You save:  ₹2,534.04
RM312.68
List Price:  RM446.70
You save:  RM134.02
₦118,358.68
List Price:  ₦169,091.08
You save:  ₦50,732.40
₨19,451.98
List Price:  ₨27,789.74
You save:  ₨8,337.75
฿2,421.30
List Price:  ฿3,459.15
You save:  ฿1,037.85
₺2,419.75
List Price:  ₺3,456.94
You save:  ₺1,037.18
B$406.81
List Price:  B$581.19
You save:  B$174.37
R1,266.21
List Price:  R1,808.95
You save:  R542.74
Лв131.43
List Price:  Лв187.77
You save:  Лв56.33
₩98,455.31
List Price:  ₩140,656.47
You save:  ₩42,201.16
₪260.61
List Price:  ₪372.31
You save:  ₪111.70
₱4,125.84
List Price:  ₱5,894.31
You save:  ₱1,768.47
¥10,813.84
List Price:  ¥15,449
You save:  ¥4,635.16
MX$1,432.62
List Price:  MX$2,046.69
You save:  MX$614.07
QR256.35
List Price:  QR366.23
You save:  QR109.88
P959.91
List Price:  P1,371.36
You save:  P411.45
KSh9,063.70
List Price:  KSh12,948.70
You save:  KSh3,885
E£3,476.67
List Price:  E£4,966.88
You save:  E£1,490.21
ብር8,762.26
List Price:  ብር12,518.05
You save:  ብር3,755.79
Kz63,877.12
List Price:  Kz91,256.94
You save:  Kz27,379.82
CLP$68,152.06
List Price:  CLP$97,364.26
You save:  CLP$29,212.20
CN¥507.37
List Price:  CN¥724.85
You save:  CN¥217.47
RD$4,236.71
List Price:  RD$6,052.70
You save:  RD$1,815.99
DA9,355.50
List Price:  DA13,365.57
You save:  DA4,010.07
FJ$159.32
List Price:  FJ$227.62
You save:  FJ$68.29
Q542.77
List Price:  Q775.43
You save:  Q232.65
GY$14,710.67
List Price:  GY$21,016.15
You save:  GY$6,305.47
ISK kr9,775.50
List Price:  ISK kr13,965.60
You save:  ISK kr4,190.10
DH703.21
List Price:  DH1,004.63
You save:  DH301.41
L1,276.61
List Price:  L1,823.81
You save:  L547.19
ден4,112.73
List Price:  ден5,875.58
You save:  ден1,762.85
MOP$563.70
List Price:  MOP$805.33
You save:  MOP$241.62
N$1,272.29
List Price:  N$1,817.64
You save:  N$545.34
C$2,573.53
List Price:  C$3,676.63
You save:  C$1,103.10
रु9,461.06
List Price:  रु13,516.38
You save:  रु4,055.32
S/267.08
List Price:  S/381.56
You save:  S/114.48
K283.05
List Price:  K404.37
You save:  K121.32
SAR262.80
List Price:  SAR375.44
You save:  SAR112.64
ZK1,938.90
List Price:  ZK2,769.98
You save:  ZK831.07
L334.76
List Price:  L478.25
You save:  L143.49
Kč1,707.89
List Price:  Kč2,439.96
You save:  Kč732.06
Ft27,663.65
List Price:  Ft39,521.19
You save:  Ft11,857.54
SEK kr779.03
List Price:  SEK kr1,112.95
You save:  SEK kr333.92
ARS$70,272.32
List Price:  ARS$100,393.34
You save:  ARS$30,121.01
Bs485.83
List Price:  Bs694.07
You save:  Bs208.24
COP$310,661.31
List Price:  COP$443,820.90
You save:  COP$133,159.58
₡35,743.76
List Price:  ₡51,064.70
You save:  ₡15,320.94
L1,776.85
List Price:  L2,538.46
You save:  L761.61
₲551,865.53
List Price:  ₲788,413.13
You save:  ₲236,547.59
$U2,996.30
List Price:  $U4,280.61
You save:  $U1,284.31
zł292.33
List Price:  zł417.63
You save:  zł125.30
Already have an account? Log In

Transcript

Video 2.3 running node red locally on your computer. In this video, we will learn why you should install Node red on your local machine, how to install and deploy node red on your local computer, be it a Windows or a Mac, and how to secure your node red editor. Now, you may have a Windows machine or a Mac machine, not to worry, we will cover both. First, we look at the installation of node red on Windows. OK, but why should we install Node red on Windows while we have already installed it on IBM, which has way more advantages than the local machine? Well, if you want to run applications in your own server, or if you want to store some data in the database running on your machine, or if you want to run applications on your machine offline Then installing node red on your local machine would be the best way.

Okay, let's start again. Yeah, there are many ways to install it, but we'll go with the simplest way. These instructions are specific to Windows 10, but should also work for Windows seven and Windows Server from 2008 or two. It is not advisable to use versions prior to Windows seven or Windows Server 2008 or two due to lack of current support. We all know that node rate runs on node j s. So the deploy node red on your local machine, we must make sure that we have Node JS. To install Node j s, go to the link I've given in the resources.

Choose the first option LTS or long term support because it's the safest bet. Make sure the downloadable link comes under Windows. Then once the installer has been downloaded the run it to install Node j s, you will be needing local administrator permissions for this. Note that NPM package manager also gets installed along with node j s. Now after the installation completes, close any open command prompts and reopen it to ensure the new environment variables are picked up. Environment Variables are nothing but dynamic objects on a computer, meaning they have an editable value, which is used by one or more software programs on Windows to know what directory to install the files in where to store temporary files and where to find user profile settings. To check if it has been installed, we can do a version check.

Go to the command prompt Again, you can use PowerShell as well, which has an advantage over command prompt because it recognizes the most basic Linux commands type the command node version and NPM version. You should see an output similar to this. Okay, now that you've installed node GS, we can install Node red using the command npm install g unsafe node red Okay, while you can understand npm install Node red What do you think G and unsafe are these are called flags. The G flag is used to install Node red as a global module, which adds the command node dash red to your system path. That is the PATH environment variable now we'll be installing node red. With the G flag enabled.

The unsafe burn flag is used to give root permissions while installing node red. This flag helps in continuing the installation in the event of an error. If you want to know what happens if you install Node red without g flag, which you should, then I have mentioned how to uninstalled node red at the end of this video, so that you can follow the video without any trouble. Check out the link in the resources, which tells you how to upgrade node red and Node JS. Once node red has been installed, and since we've installed node red as a global NPM package, use the command node dash red to start node red. In case you've installed node red without using the G flag, then you can start node red using the command node node underscore modules, backslash node hash rate, backslash red.js.

Run this command within the directory where you ran npm install. The command starts outputting node red logs in the terminal, it might take some time for setting up the node read environment. You know the setup is done. When you see the text started flows on your console. The console stays open and shows the log info of the flows, which provide a lot of information. Like you can see the versions of node red and Node JS installed on your machine.

You can also see the location of important files in Node red, and the log also shows the URL to access the web based editor. Use it to open the web based node read editor. Note that the given URL is 127 dot zero dot zero dot one colon 18. At the port number 1880 is used by note rate, which is a TCP UDP port. The IP address 127 dot zero dot zero dot one corresponds to localhost, which means instead of that URL, you can also use localhost colon 8080 to access the node red editor. One important thing to note is that to keep node rate running, we must keep the terminal open.

You can close the console by pressing Ctrl C. At first boot, the necessary directories and files like settings.gs flow file and use a directory will be created automatically. OK, okay, so what are those files? Exactly? Let me show you We have to go to dot node red, which is a hidden file. And here it is. Of these package dot Jason, and settings.js are the most important files.

I'll teach you about package dot Jason later in this course. settings.js is a settings file, which is the first to run when the node rate starts. This file sets the admin port, user directory, the flow file, etc. If you want to configure node rate, then you must go for this file. This file exports the GS object, which is what is passed through the nodes getting modified at every node. Note that these files will also be present in the IBM Cloud platform in the get repository under the DevOps tool chain.

We look into them later. You can also use your own my settings.js file instead of the default one. If you want to do that, use the switch flag while running the node red start command node dash rate dash s, my settings.js. If my settings.js was the only settings file present inside the dot node red directory, then it will be used by default. The second stage of starting node red involves setting up the user directory, which is when no dread stores all user data like credentials, flow and library data. If you want to have multiple user directories, you can mention the user directory to load in the settings.js file.

By default, the user directory chosen is dot node read the user directory contains The flow file. Okay, next is a flow file, which goes by the name flows underscore server name dot Jason. This file contains all the flows in your node read editor in JSON format for easy important export. This was created the first time you ran node red, and then every time this file gets updated when you deploy a flow the third stage of starting node red is loading flows from the flow file. The flows underscore server name underscore cred dot Jason contains the login data used by some nodes. Great.

There are other ways to manage your flows as well. You can use the project feature in the node rate, which will help you in backing up your flows using the get repository Learn how to do that, check out the resources section. Did you also know that you can run multiple instances of node read on a single machine? How? Well I don't know. But we can figure out how running different instances means that multiple users can use a single application.

Remember the URL we got 127 dot zero dot zero dot one colon 1880. You can see that the port number is 1880 where we can run only one instance of node red. Okay, so if we need to run another instance, we need to have another port number done, but it is not only the port number is it remember I told you about the user directory will the user directory will have the flow file which will contain all your flows So can the user directory be shared among different users? There is no way I'm sharing it with someone. So to avoid conflicts, we will have to have different user directories. So either you can have a different port, and a different user directory for each instance, or create and use a new settings.js file for each instance.

To check out how that works. Look for a link in the resources. Note that this is different from sharing node read with different uses of a computer. Many Node JS modules used by node red are installed nodes have binary components that will need compiling before they will work on Windows. To enable NPM to compile binaries on the Windows platform, install the windows build tools module using the command prompt as an administrator npm install global production windows build tools. Once you install the module, close and open your command prompt window for the changes to take effect, check out the link in the resources, which teaches you how to auto start node red, running on Windows on both.

Okay, now that we have a node red running, and we can access our editor to create and deploy applications, remember that according to the prophecy, the notary running on your machine can easily be hacked. Because out of the box, it is not secure. To prove the prophecy wrong, we need to secure our node red. This can be done in two ways. username or password credential based authentication, authentication against any OAuth or open ID provider, such as Twitter or GitHub. But I'm gonna go with credential based authentication.

Because it is the easiest way, we can authenticate node red platform in three ways, two of which we'll be seeing later. First, we need to secure the node red editor. For that, we need to change the settings.js file. Don't get overwhelmed by the number of code lines in this file. We will not be using much of it, but I'll explain whatever we use as in when necessary. We can secure node red editor by uncommenting, the admin author lines.

Here, you can see that there are already some credentials admin as username and password as a password, except that it is securely hashed using the bcrypt algorithm. The star denotes that the user has full access to the editor. Notice user's property is an array of user objects. This allows you to define multiple users, each of whom can have different permissions. Since everyone knows the password, it has to be changed. Add your username and password, but we have to enter the hash one.

And how can we hash it? Note rate admin comes to save the day. No dread admin is a tool to administer no dread from the command line. It provides a command to create a password hash. To use it, we have to first install it Any guess as to what the command could be? Well, it must have these keywords NPM G, node, red admin and install so let's check npm install g No dread admin.

Bingo. It is getting installed. Great. Okay, let's try the command to generate hash, no dread admin hash pw you have to enter the password to generate the hash. And there it is. Copy and paste it there and save it.

Note that whenever you change node read files, you have to restart it for the changes to take effect. So let's do it. Okay, now hopefully, we have falsified the prophecy. Let's check it to be sure. Fantastic. Now you can run your applications without worrying about your editor getting hacked.

Okay, good. Like I promised before, let me show you how to uninstalled no dread in Windows. is the same as the first command, except that the key word will be uninstalled. Instead of install. Next, you have to clean the cache by using the command NPM cache clean force G and use the command NPM LS g depth is equal to zero to check if all the modules have been uninstalled. Now we can move on to installing node red in Mac, installed Node JS the same way we installed it on Windows, then check if it has been properly installed by checking the version then run the command to install Node red.

The command is similar, but within addition sudo which will give root user access if you are not running as the root user. This command doesn't exist in Windows after installation run node dash red command to start node red, you can access the editor from a web browser. Here, you can see that there are some pre installed nodes for Mac. Anyway, if you want to add more, you can always use the Manage palette option. The dot node red folder is a hidden folder, which cannot be seen in the Mac by default. To view it, go to Macintosh HD, and hold down Command shift.to.

View hidden files and press it again if you want to hide them. Or Also, you can find the dot node red folder inside the home directory. And there you go. You have all the files, you can secure the node red editor the same way we saw in Windows. Okay, in this video, we've learned why we should integrate All no dread on your local machine, how to install and deploy no dread on your local computers, be it a Windows or a Mac, and how to secure your node raid editor. In the next video, we'll learn how to deploy node red in a single board computer.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.