I edited a module .js file and now I can't deploy, how to recompile?

HI mates, I got a trouble, since “node-red-contrib-i2c 0.5.2" has an uncomfortable behaviour sending to I2C device a static command in anycase, and I need all datas to be dynamic, so I tried to change myself the script. I stopped service, edited, saved and started again, but haven't noticed changes. This way it work for modules .html files, but not for js now I realized, I suppose they should be compiled, and it has been done probably when I installed them.
Anyway to make it work I rebooted, and now I can't use more those modules,
Flows stopped due to missing node types.
i2c in
i2c out
And on console I have:
Waiting for missing types to be registered:
16 Jan 22:56:20 - [info] - i2c in
16 Jan 22:56:20 - [info] - i2c out

Maybe I made a mistake in .js, which I corrected now, but how can I recompile/register the module again?
I executed npm rebuild under /home/pi/.node-red/ folder and I reboot too, but not solved..

Another question, is the file .json used during the installation (inside the module .zip) a way to control hash of the file and avoid any modifications? For this reason I can't use it more?
I don't understand, if modules are compiled, why after edit and reboot it de register the module? I didn't delete any file! just created a backup copy of file .js in the same folder, is this the problem?
Thank you a lot!

Under folder /home/pi/.node-red/ i executed npm remove node-red-contrib-i2c and after npm install node-red-contrib-i2c and I rebooted, solved.
Anway I would like to know how can I edit safely this .js, thank you!

It means that whatever you did to that was wrong and you broke it.

You will need to go back and work out what you did wrong.

You need to understand JavaScript, how Node-RED custom nodes in general work and how that specific node works.

1 Like

Hi! May you kindly let me know how Ned RED consider it "broken"? Does it recompile custom modules every time the service starts? (after reboot, because just a stop/edit/start didn't produce noticiable effect). Or does it make a checksum calculation about the files present in folders and any ".md5" information stored somewhere?

And again, when I install a new modules, is the installing process compiling it, and only the installation process? How and I force recompile it eventually?
To solve my situation I had to install module (by palette menu) again, it overwritten all. I overcomed the problem elsehow by the function.
Yes I've learned javascript, and I?m sure wthe edit I did where just small and should work, well after the first time I noticed a small error but from that time I couldn't fix and recompile myself.
I would appreciate if someone can clear me about this issue, how Node Red deal with modules, thank you

No. You need to understand that Node-RED is built using Node.JS so when you make a change to a JavaScript file, there is no recompilation involved. However, if your change results in an error, that will be propagated up to Node-RED. That is what will have happened in this case.

There is no way for anyone to predict what that error is without knowing what you changed, where and how. It could be a coding error or it might be something structural that either the node itself or Node-RED is expecting that you are either no longer doing or doing incorrectly.

In your case, the most likely thing is that you've changed something and now Node-RED can no longer process the node in a way that it recognises.

No, when Node-RED starts, it imports the various node modules and runs the setup. There is a section in the nodes js file that is then called whenever a message passes through it.

You should go back and read the docs on creating custom nodes. You might also like to look at my dummy test node node-red-contrib-jktesting which has loads of comments in it - I created it as I was learning about creating my own custom nodes.

If you have cloned the node from GitHub, perhaps try using Git to commit your changes - then you can undo them if something breaks.

JavaScript can be challenging to work with if you are used to compiled languages. I also recommend using a good editor such as VSCode with the ESLint extensions. ESLint will give you lots of information when you make mistakes in your code.

Very useful, thanks!
Some questions still uncleared for me but before asking I'l read your guide!