How to Load External Modules

Home > Guides

Steps:

    1. Install the necessary Node.js package:

      If the appropriate package is not installed on the target machine, please do so following the directions provided by the package instructions. Typically, it is accomplished as follows:

        sudo npm install {package name}

    2. Open settings.js file with nano:

      sudo -s
      [sudo] password for debian:
      cd /root/.node-red
      nano settings.js

    3. Edit ‘functionGlobalContext’ in settings.js:

      To make the os, bonescript and moment node.js modules available to Node-RED, edit the settings.js file as shown below (Tip: Make sure to use commas correctly)

        functionGlobalContext: {
        os:require('os'),
        bonescript:require('bonescript'),
        moment:require('moment')
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
        },

      Save and exit the settings.js file.

    4. Stop and start Node-RED for the changes to take effect.

      Stop Node-RED:

        sudo service node-red stop

      Start Node-RED:

        sudo service node-red start

References: