I am using Node-Red version 3.1.3 (docker image nodered/nodered:latest) and I fail to get anything related to externalModules to work. I can add modules in function nodes but I can not get any modules to be loaded. There are no signs of the externalModules settings to impact the pallet editor. The only thing I can install using the pallet are from the Community catalogue.
Any ideas what I am missing or what could be wrong?
I have entered the module āquine-mccluskey-jsā in the function nodeās startup form.
Where do this package have to be placed?
There is a lot of information in the default settings.js file regarding externalModules (e.g. regarding the pallet-editor) is this information āwrongā?
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.
I realised that just after sending the question, sorry.
However patching the package.json file made node-red accept the package, and my function node is now working.
Thanks for helping me with the problem.
Any info regarding all the externaModules stuff in the settings.js file that does not seem to be āapplicableā ?
Yes, I have already sent a message to the developer.
My fix was just to see if I could get it to work. In case developer will not respond I will probably make a fork of the project.
Again, anything regarding the info in the settings.js file? Is it wrong, outdated, ā¦?
enable/disable the feature to allow function nodes to use / install external modules (as you are doing)
add modules at a global level, so all function nodes can see it (regardless of the above setting) but this will require you install the module your self
But note that if you have updated node-red then the settings file will not be updated to the latest version as that could overwrite modifications you have made. There could therefore be obsolete data there.
externalModules
Generally controls what access the pallette menu has (a lot is on by default)
functionExternalModules
Allows / Disallows function nodes to install/use external modules for them self
functionGlobalContext
Exposes modules for all function nodes (Regardless of functionExternalModules)
but this method require that you do global.get("key") in the function node
I enabled all these settings but nothing showed up un the pallet manager. Is there some example somewhere where it is described what each of these settings actually do.
I might have the wrong expectations and that could be why I do not experience any effect of these settings. Anything that would clarify would be helpfull.