[[EDIT: I figured it out! See my below reply!]]
It is happening again! arrrgh
I put this in a function node:
var tinycolor = global.get(‘tinycolor2’);
var color = tinycolor(msg.payload);
var triad = tinycolor(msg.payload).triad();
triad = triad[1];
msg.payload = tinycolor(triad).toHexString()
return msg;
…the first thing I do is check the log and I got this:
sudo systemctl status node-red
Jun 11 17:51:12 vBBB13 Node-RED[874]: 11 Jun 17:51:12 - [error] [function:98da5b88.85cc68] TypeError: tinycolor is not a function
[[[NOTE: why didnt it complain about the global.get first?]]]
ok, the first settings.js file that I will try is this one:
/root/.node-red/settings.js
I add this:
functionGlobalContext: {
// os:require(‘os’),
tinycolor2:require(“tinycolor2”)
// j5board:require(“johnny-five”).Board({repl:false})
},
…and restarted node-red and got this:
Jun 11 18:03:42 vBBB13 systemd[1]: Started Start Node-RED.
Jun 11 18:03:48 vBBB13 Node-RED[925]: Error loading settings file: /root/.node-red/settings.js
Jun 11 18:03:48 vBBB13 Node-RED[925]: Error: Cannot find module ‘tinycolor2’
so, lets install “tinycolor2” in this location:
/root/.node-red
before doing anything I have this:
root@vBBB13:~/.node-red# ls
flows_vBBB13.json lib node_modules package.json settings.js
root@vBBB13:~/.node-red# cd node_modules/
root@vBBB13:~/.node-red/node_modules# ls
[[[[nothing was there]]]]
root@vBBB13:~/.node-red# npm install tinycolor2
node-red-project@0.0.1 /root/.node-red
└── tinycolor2@1.4.1
npm WARN node-red-project@0.0.1 No repository field.
npm WARN node-red-project@0.0.1 No license field.
now it is there
root@vBBB13:~/.node-red# ls
flows_vBBB13.json lib node_modules package.json settings.js
root@vBBB13:~/.node-red# cd node_modules/
root@vBBB13:~/.node-red/node_modules# ls
tinycolor2
…but I restart node-red and I still get this:
root@vBBB13:~/.node-red/node_modules# sudo systemctl status node-red
● node-red.service - Start Node-RED
Loaded: loaded (/lib/systemd/system/node-red.service; disabled; vendor preset: enabled)
Active: active (exited) since Mon 2018-06-11 18:09:08 EDT; 9s ago
Process: 967 ExecStart=/usr/bin/node-red.sh (code=exited, status=0/SUCCESS)
Main PID: 967 (code=exited, status=0/SUCCESS)
Jun 11 18:09:08 vBBB13 systemd[1]: Started Start Node-RED.
Jun 11 18:09:15 vBBB13 Node-RED[967]: Error loading settings file: /root/.node-red/settings.js
Jun 11 18:09:15 vBBB13 Node-RED[967]: Error: Cannot find module ‘tinycolor2’
What am I doing wrong?