10 Mar 2016

Install Node Red

Node Red is an exciting platform for wiring together the Internet of Things or any web services. The installation instructions are provided here but don't forget to install Node.js and setup the startup/shutdown scripts. These steps also describe how to upload your own nodes for testing purposes.

Install Node.js

First install Node.js.  If you're not sure if it's already installed, run the command nodejs -v.

sudo apt-get install -y nodejs

Install NPM

Install the Node Package Manager

sudo apt-get install -y npm

Install Node Red

Install Node Red

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

Start Node Red Manually

Before we go further, let's make sure Node Red runs correctly by starting it manually and connecting to the web interface:

sudo service nodered start

Uploading Your Own Nodes for Testing

Create a directory to hold the files associated with your nodes. My node is called apic and the directory I created is:

/usr/local/lib/node_modules/node-red/nodes/local/apic

From here I upload my package files to this directory.

Restart Node

With my package files uploaded, I now need to restart node:

sudo service nodered restart

Refresh the browser and you should see your new nodes.

Logging

If you use the log calls to troubleshoot your node development, you can file the messages written to the file:

/var/log/node-red.log

Here's the full command I enter after uploading new node files to my home directory:

mv ~/apic* /usr/local/lib/node_modules/node-red/nodes/local/apic; sudo service nodered restart; tail -f /var/log/node-red.log

Additional Nodes

There are some additional nodes I like to add. You'll find a searchable list of nodes here. You must run the npm install command from the user directory associated with your install. You can find this directory by search for this record in the /var/log/node-red.log file:

 User directory : /root/.node-red

Once you have this directory, execute the commands to install:

sudo npm install --prefix /root/.node-red node-red-node-mongodb

Now, restart the server:

sudo service nodered restart

Tags:
0 comments