Hi, I was probably running NR 1.35 before his, on the flow I copied a previous function node, canged inside a string under " " only, and I got the error sign, and when I open function I can't see more the debug that told me where the problem is. There is something wrong with my installation? Thank you
This is the code:
var messaggio;
var chatId=global.get("LatestchatId");
if (chatId===undefined) {chatId=956528929;}
if (msg.payload) {messaggio="VPN Domotica abilitato";} else {messaggio="VPN Domotica disabilitato";}
var res = "|Raspberry|: "+messaggio;
msg = {payload:{chatId: chatId, type:"message", content:res}};
if ((chatId!=956528929) & (global.get("NotificheRete"))) {
msg2 = {payload:{chatId:956528929, type:"message", content:res}};} else {msg2=null;}
return [msg,msg2];
I can't understand more where the debug is, how can I know there mistakes are? I can see some red stripes on right coloumn but if I click I don't have reactions
This is due to 3x moving to monaco editor, and reporting more errors in the function editor.
You have not declared msg2 with var, let or const. The red section at right side shows where the error is and msg1 is underlined with a red squiggly line.
Thnaks for reply, no it's not, also this code doesn't work. I'ts strange that in other functions there is the same code but no error, just because I have no edited them after 3.02?
var messaggio; var msg2; var msg;
var chatId=global.get("LatestchatId");
if (chatId===undefined) {chatId=956528929;}
if (msg.payload) {messaggio="VPN Domotica abilitato";} else {messaggio="VPN Domotica disabilitato";}
var res = "|Raspberry|: "+messaggio;
msg = {payload:{chatId: chatId, type:"message", content:res}};
if ((chatId!=956528929) & (global.get("NotificheRete"))) {
msg2 = {payload:{chatId:956528929, type:"message", content:res}};} else {msg2=null;}
return [msg,msg2];
If I select all text, and only if I select text, I got an icon where the error is, but it doesn't tell me which error is. I can only ignore/etc.
Frankly I don't like this editor, it doesn't help me,opposite it halts me and, even if I'm wrong bucause I can't figure out how it works, I have the feeling it will slow down my work in future.
Any chance to go with the provious editor?
Thanks
with let msg2 = {}; it works, this is horrible news for me, should I correct all the functions of enterely code? They are more than 400!!!
I'm thinking to downgrade NR, possible?
I confirm that also & is resulting an error now. Mates I'm really worried, I can't sustein a version of NR with editor that is not reporting me more the mistakes and that impose me to correct all code I did previously, I'm really worried.
Please tell me I have chances to revert back to previous version without this problems, and without creating problems to nodes installed after the downgrade.
I'm sad ((((
You can go back to the old ACE editor if you don't want to benefit from the richer features of the monaco editor.
In your settings.js file, under editorTheme you should find a codeEditor section, and in that a property called lib. Set that to ace.
Depending how old your Node-RED instance is, it is possible you don't have some of these sections in your settings file - so you'll have to add them.
editorTheme: {
codeEditor: {
lib: "ace"
}
}
Just remember to backup your settings file before you make changes incase you get the syntax wrong.
Just to add... the monaco editor is telling you about improper javascript code. It won't stop your flows from working - its just warning you. You could choose to ignore it, and fix the syntax issues in the function nodes gradually over time.
In general, best not to completely replace things so you don't remove settings you already had. In this instance, the projects setting you had set to the default value so it doesn't matter that you removed it.
Are you sure you've edited the right settings file? Node-RED logs the full path to the settings file it is using when it starts up.
Yes I'm sure is the same path, I've just verified it again.
How should then I write properly into that file? I'm getting a bit confused, why I don't see any result?
Sorry, I forgot to refresh the page. I did and the editor is ace, good.
Please one more question, if I understood right I don't need to worry about the fact I removed projects setting, right?
Sorry mates I appreciate your effort you improved the interface and syntyax correction, but really I can't correct all this code, I have too many risk it will not work after and I can't take this risk. I prefer stay old and dont' see errors, all is working by the way and stable, for me is ok. Plus I can see where my mistakes are, sorry but with new interface I've checked everwhere and I haven't see the help. I have no choce and I'll stay old
Problem solved, thanks!
You might consider stopping Node-red, renaming settings.js and restarting NR.
This will create a new default settings.js file including all the goodies introduced since your v1.3.5
Compare it with the backup copy to see what you were missing.
You can then edit it and change the word "monaco" to "ace" to ensure you can continue using variables without declaring them first.
Note that where you had & instead of && is a real error, the meaning is different. Under some circumstances the effect is the same, but a subtle change in the data could make it fail at some point in the future. Such errors can be extremely difficult to find. That is why it is worth using the new editor, and each time it points out a problem then fix it. One such subtle bug could take you much longer to find than it would take to fix the issues now.
Also you will presumably continue to include errors in new code. If you are using node-red in a work environment then your employer will not thank you if you leave behind poor quality code for the next guy to fix.
Ok mates, I'll consider it, first I'll try to rebuild the settings.js using the new generated one as jbudd suggested, then I'll evaluate if I can debug function with an error reporting interface. Since now I haven't seen it and I couldn't work without it.
Then if I can find it helpful, as for sure it will be, then I'll evaluate to correct all the code time by time.
Pity that during the upgrade the settings.js hasn't been properly refreshed, since this I opened this topic, now all has sense. Thank you again
One of the features introduced in more recent releases is Node-red lint.
I'm not very familiar with it so I have no idea if it will highlight all the occurrences of uninitiated variables, & where you should have && and || where you should have ??.
Worth a look at least, it might give you an idea of the size of the debugging task ahead.
Another way to locate all the & would be to export your entire flow (in 'pretty' format) and save it to a file.
Then edit the file and do a search for &. Then you can find that node's id. Next, in NR, do a 'find' using that id and change the node...
OR, if you need to change all the occurrences, you could do a global replace while editing the file. Then you would stop NR and rename the existing flow file (the default name is flow.json) to something like oldflow.json. Start NR and import the changed file.