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.
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 mysql.
The error means you have a syntax error in your settings file. Double check you have added the property correctly.
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’).
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.