Can not get externalModules to work

This is how I add external modules to my docker instance for use inside the function node.

This example I'm adding xlsx from sheetjs

Get the ID of the node-red container

$ docker ps

Installing npm module (make sure to change the ID to the one you got from $ docker ps)

$ docker exec -it f534d7069634 /bin/bash
$ cd /data
$ ls
$ npm install --save https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz

edit the settings.js file to use this module.

functionGlobalContext: {
         XLSX:require('xlsx'),
    },

now in nodered's function module I can use it like this:

var XLSX = global.get('XLSX');
msg.payload = XLSX.version;
return msg;

I don't like the new system and installing version specific modules has been an issue for me. Until there is a good howto on the new system, installing inside the editor, I'll keep installing modules the old way.

1 Like