Hello. I am new using node-red. I've only been working with this system for a couple of months. So far I'm doing fine, but my first problem that I can't solve happened when I tried to compile the nodes node-red-node-mysql and node-red-contrib-stackhero-mysql to connect to a mysql database that I have installed on the local server where node-red is installed. A PC with w10 64bit. With any of these two nodes, just at the moment that I finish parameterizing with the data of my database and execute a deploy, the node-red collapses, stops and shows the error that I share below. I cannot parameterize any node to connect to my database that does not stop the node-red abruptly. I use a database server running on wampserver 3.2.6. The wampserver has mysql version 5.7.36 and mariaDB version 10.6.5.
Below I share the error code. I would greatly appreciate your help:
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\home.node-red\node_modules\iconv-lite\encodings\index.js:6:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.getCodec (C:\Users\home.node-red\node_modules\iconv-lite\lib\index.js:63:27)
at Object.getDecoder (C:\Users\home.node-red\node_modules\iconv-lite\lib\index.js:125:23)
at Object.exports.decode (C:\Users\home.node-red\node_modules\mysql2\lib\parsers\string.js:10:25)
at Packet.readNullTerminatedString (C:\Users\home.node-red\node_modules\mysql2\lib\packets\packet.js:398:25)
at Function.fromPacket (C:\Users\home.node-red\node_modules\mysql2\lib\packets\handshake.js:62:33)
at ClientHandshake.handshakeInit (C:\Users\home.node-red\node_modules\mysql2\lib\commands\client_handshake.js:93:40)
at ClientHandshake.execute (C:\Users\home.node-red\node_modules\mysql2\lib\commands\command.js:39:22)
You should fix that error! You need to open the MySQL node and enter the configuration information.
If NR crashes at startup, run it in safe mode. Add --safe (two dashes) to the end of the startup command. So if your flow is ‘my.flow’ you would use node-red my.flow --safe This will allow you to use the editor and configure the MySQL node and deploy.
A side question: why are you using two different MySQL nodes?
Hello. thank you very much for your help. I am not using two mysql node, initially I tried node-red-node-mysql and it installed correctly but when configuring it and executing deploy node-red crashed. then I thought it was a problem with node-red-node-mysql, I uninstalled it and installed node-red-contrib-stackhero-mysql to test, it was also installed correctly and when I configured the data of my database server and executed deploy
the same error occurred, the node-red crashed too, and it was the log I shared above.
If I remove both nodes, the node-red works perfectly, that is, all the other flows work fine. I have nodes that read through modbus from a PLC, I have nodes that send data by telegram and by whatsapp and everything works, except when I configure any of these two mysql nodes, which from the moment I configure the database server and I hit deploys, everything stops. To load NR again I have solved by executing NODE-RED CLEAR on some occasions and on others I have had to delete the mysql node folder in the path ....node-red\node_modules .
I have already executed the node-red myflow --safe command and I get the same problem.
Thank you very much for continuing to support me. I remind you I don't have much experience in using node-red. I also apologize for my English, which is not very good, because my main language is Spanish.
Please try this.
1 - stop node-red
2 - start node-red with a new flow `node-red testmysql.flows
3 - add in the one of the MySQL nodes, configure it and deploy
Does it cause an error?
If it doesn’t try adding enough nodes to actually query the DB and see what happens.
Same thing. Same problem
just before de fallowing line i press "Deploy" after configured de DB parmeters, them crash:--- 10 Apr 16:16:38 - [red] Uncaught Exception:
Here the full log:
Your environment has been set up for using Node.js 16.13.2 (x64) and npm.
C:\Windows\System32>node-red testmysql.flows
10 Apr 16:14:51 - [info]
Welcome to Node-RED
===================
10 Apr 16:14:51 - [info] Node-RED version: v2.2.2
10 Apr 16:14:51 - [info] Node.js version: v16.13.2
10 Apr 16:14:51 - [info] Windows_NT 10.0.10240 x64 LE
10 Apr 16:14:53 - [info] Loading palette nodes
10 Apr 16:14:56 - [info] Dashboard version 3.1.6 started at /ui
10 Apr 16:14:56 - [info] Settings file : C:\Users\home\.node-red\settings.js
10 Apr 16:14:56 - [info] Context store : 'default' [module=memory]
10 Apr 16:14:56 - [info] User directory : \Users\home\.node-red
10 Apr 16:14:56 - [warn] Projects disabled : editorTheme.projects.enabled=false
10 Apr 16:14:56 - [info] Flows file : \Users\home\.node-red\testmysql.flows
10 Apr 16:14:56 - [info] Creating new flow file
10 Apr 16:14:56 - [info] Server now running at http://127.0.0.1:1880/
10 Apr 16:14:56 - [info] Starting flows
10 Apr 16:14:56 - [info] Started flows
10 Apr 16:16:38 - [info] Stopping flows
10 Apr 16:16:38 - [info] Stopped flows
10 Apr 16:16:38 - [info] Starting flows
10 Apr 16:16:38 - [info] Started flows
10 Apr 16:16:38 - [red] Uncaught Exception:
10 Apr 16:16:38 - [error] C:\Users\home\.node-red\node_modules\iconv-lite\encodings\internal.js:1
$�)
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\home\.node-red\node_modules\iconv-lite\encodings\index.js:6:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.getCodec (C:\Users\home\.node-red\node_modules\iconv-lite\lib\index.js:63:27)
at Object.getDecoder (C:\Users\home\.node-red\node_modules\iconv-lite\lib\index.js:125:23)
at Object.exports.decode (C:\Users\home\.node-red\node_modules\mysql2\lib\parsers\string.js:10:25)
at Packet.readNullTerminatedString (C:\Users\home\.node-red\node_modules\mysql2\lib\packets\packet.js:412:25)
at Function.fromPacket (C:\Users\home\.node-red\node_modules\mysql2\lib\packets\handshake.js:62:33)
at ClientHandshake.handshakeInit (C:\Users\home\.node-red\node_modules\mysql2\lib\commands\client_handshake.js:98:40)
at ClientHandshake.execute (C:\Users\home\.node-red\node_modules\mysql2\lib\commands\command.js:45:22)
C:\Windows\System32>
Have you recently upgraded node-red and/or nodejs?
e.g. was node-red and node-js previously installed and updated to newer versions?
This is most odd. Almost like there is corruption - possibly in your .node-red\node_modules, possibly in your global nodejs installation.
Could you setup a mysql node and its config so that this happens again & export it (select the mysql node, press CTRL-E to export, paste into a reply) - NOTE - password and user name will not be exposed (credentials are not exported).
I will look see if there are any odd characters in the export.
In the mean time, if you want to proceed, the next step I suggest is to assume there is a problem with the .node-red\node_modules part (after that would be to remove and re-install nodejs)
shut down node-red
open c:\users\home in your file explorer
locate the folder .node-red
you might need to switch on show hidden files and folders in explorer options
rename .node-red to .node-red-old
start node-red
this will re-create the folder c:\users\home\.node-red
install (from the palette manager) node-red-node-mysql
try a simple demo (inject topic=select * from datos --> mysql --> debug)
You can always switch back to (or simply import your old flows into the fresh node-red) from the back-ed up folder C:\Users\home\.node-red-old (i.e. you wont lose anything trying this)
Hello.
Below I share the result of executing CTRL-E in the configured mysql node and just before executing a DEPLOY. Remember that if I press DEPLOY after configuring node mysql node-red crashes.