Node 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.
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
- Static Content
- Authentication
- Adding additional node modules
Important 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 un commenting 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” },
Static Content
This is important when using images in your flows or using node-red to serve web pages
uncomment and edit the line httpStatic as shown below:
httpStatic: ‘/home/pi/.node-red/staticContent/’,
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.
Common Questions and Answers
Q – I see the pathname like this –
//userDir: '/home/nol/.node-red/',
Where is the nol folder?
A- The nol folder is the home folder for Nick O’Leary and is there as an example you need to use your own home folder name there.
Resources:
Related Tutorials
hi, I am getting a issue on httpstatic content, my static content folder location is
httpStatic: ‘/seema/.node-red/static/’, in setting.js file
When I am trying to access web static page I am getting error
http: 127.0.0.1:1880/test12.jpg
Cannot Get /test12.jpg
help me out, thankyou sir.
The http static file location doesn’t look correct I think it should be
httpStatic: ‘/home/seema/.node-red/static/’