Node-Red Settings.js File – Node-Red Admin

node-red-settings.jsNode red uses a settings file called settings.js located in in the user .node-red (dot node-red) folder in their home directory.

You can create your own settings file and customise it either by copying the existing file or using the file available from Github here.

On Linux the settings.js file is copied from the /usr/lib/node-modules/node-red/ folder to your .node-red folder in your home directory when you start node-red, and there is no settings.js file present.



On windows if no settings.js file is present in the home folder then the node-red start process stops with an error.

windows-node-red settings file

The default settings.js file is mostly commented out.

To use your own settings file use the -s switch when starting node-red e.g.

node-red -s mysettingsfile.js

The documentation here takes your through the settings file in detail.

Common Changes

  • Alternative flow file
  • Alternative port
  • Alternative UI url
  • Authentication
  • Adding additional node modules

Note: The settings.js file is a JavaScript object so pay attention to the commas at the end of the lines

Alternative flow file – By default node-red will use the flow file called machine_name.json e.g. steve-laptop.json.

You can change this in the settings file by uncommenting and editing the line:

//flowFile: ‘flows.json’,

e.g.

flowFile: ‘mylows.json,

Alternative port – Edit this line and change 1880 to the required port number.

uiPort: process.env.PORT || 1880,

e.g.

uiPort: process.env.PORT || 1888,

Alternative UI url -This the the path to the dashboard which you normally access using

http://localhost:1880/ui

uncomment and edit the line:

//ui: { path: “ui” },

e.g.

ui: { path: “mydashboard” },

 

Authentication -There are three places were you can configure authentication.

  • The Admin console- Node red editor
  • Nodes
  • Static Pages

This is covered in detail in this tutorial
Securing Node-Red with SSL and Username Authentication

Adding additional node modules – This is a very useful setting and lets you use node modules in the function node

For example, If you need to use an node module e.g the os or fs module then you need to enable them under the functionGlobalContext: object as shown in the screen shot below

To use them in the function node they are part of the global object so use:
var os=global.get(‘os’);
var fs=global.get(‘fs’);

Use Command Line Switches Alternatives

Although you can change the node-red port and flow file using the settings file you may prefer to use a command line switch instead.

Examples:

node-red - p 1888

Will start node-red using the settings.js file but on port 1888

node-red myflowfile.json

Will start node-red using the settings.js file but use the myflowfile.json file to store the flows.

Resources:

Related Tutorials

Please rate? And use Comments to let me know more
[Total: 0    Average: 0/5]

Leave a Reply

Your email address will not be published. Required fields are marked *