To give function nodes access to a local MariaDB I'm used to adding mysql:require(’mysql’)
to functionGlobalContext (in config/node-red/settings.js).
I have used this method for a number of years, last time was about a year ago but when installing Node-red on a new hassio yesterday, it no longer seems to work.
I run Node-red on Hassio ( Raspberry.py )
Do you get any error messages? What version of the
mysql npm module have you installed?
The error occurs when Node-Red is trying to start. The same actually happens when I add fs:require(’fs’) to functionGlobalContext.
The following error is seen in the log file :
node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"
Error loading settings file: /etc/node-red/config.js
-- What version of the
mysql npm module have you installed
I use the default in Hassio, version 1.0.0
It definitely helps to provide details of any errors you are seeing when asking why something isn't working. Otherwise we have no information to go on.
If it fails when you try adding
require('fs') as well, then this isn't related to
The error means you have a syntax error in your settings file. Double check you have added the property correctly.
Year, maybe I should look into home assistant instead.
Curious as to why you do not simply install node-red directly without having it as a subsystem of Hassio or HA?
It's because I also use other parts of hassio on the Raspberry.
Not being familiar with hassio myself...
Isn't it possible to install node-red and communicate with hassio without installing it as an add on of hassio?
Alternatively, if you share with us exactly what changes you've made to the settings file we may be able to spot the possible syntax error you have.
This is how my "old" setting is (with the mysql line added) :
Uncommenting os:require('os'), actually works.
Maybe support for mysql:require('mysql') has been removed or has been renamed, I don't know.
I also have to double check that all needed HA nodes is installed.
possibly you were relying on the npm module that the node node-red-node-mysql was installing
that was in turn using the
mysql library .. thats why you had access to it and could require it.
and because of the update of the node-red-node-mysql node 1.0.0 to a different library
mysql2 the old library got uninstalled.
- Have you ever manually installed in Node-red the
mysql library in order to use it ?
- If my assumptions are correct .. do you also have node-red-node-mysql installed ?
I think I have found the problem. At least I'm now able to start NR and the DB access seems to be available again. I just need to test it proberly.
It looks like newer installations of Hassio no longer have the mysql directory in /config/node-red/node_modules. Now there is a mysql2 directory present - even though the node-red-node-mysql module is still specified as beeing version 1.0.0 in Manage palette.
NR now starts if I use mysql:require(’mysql2’) instead of the usual mysql:require(’mysql’).
/ Thanks for all your feedback.
ah - so are relying on th library installed by the node-red mysql node... this change to mysql2 when we moved the node to version 1.0 - if you are just referencing node modules from a function node you need to make sure you also install the needed node module yourself into the ~/.node-red directory. I assume you didn't do that yourself so when we upgraded the module you were left referencing the old one.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.