Copying user files to new install

I am running a Node-RED dashboard on a Raspberry Pi that successfully pings a number of Home Automation devices over time and displays various metrics.

All runs OK most of the time but occasionally the Pi craps itself and crashes. I have tried to do updates and upgrades on the Pi but these too end in errors. Therefore I am thinking it would be best to effectively start again, do a brand new install of Raspbian and then set Node-RED up again.

Problem is that I'm not that techy and it has taken me a long while to get this far with my dashboard. Therefore I'm looking for the best way for me to copy across all the appropriate directories, files, settings, configs, custom fonts etc etc from the old install to the new clean one.

Is anybody able to give me some simple guidance and steps to follow?

Many thanks in advance.

If you are using a standard install, all you need to do is to copy the contents of the ~/.node-red folder.

However, you can exclude the node_modules sub-folder if you like. But once you are on the new system, go into that folder in the terminal and do npm install which will reinstall all of the dependent packages from scratch. Then you can start node-red.

1 Like

I think that, unless the new system is the same hardware, OS version and nodejs major version (not sure whether the OS matters actually) that it is essential not to copy node_modules from the original. Otherwise there is a danger that any nodes that have locally compiled components will fail. Removing node_modules and running npm install will compile them for the new system.

Sorry, I should have said that. You are, of course, correct.

I have finally gotten around to try to set this up. I ran npm install in the .node-red directory and it said it had created a lockfile as package-lock.json and that I should commit this file. I'd be very grateful if someone could tell me what all that means and what I need to do!

You do not need to do anything.

The package-lock file is a file npm generates that lists in full detail every single module that npm has installed - including all of the internal modules. This allows it to reinstall and an exact copy of the dependencies in the future - right down to the lowest level, at the exact version you installed today.

But in general, installing without the package-lock file in place will allow dependencies to be installed at the newest version permitted by all of the package.json files.

Thanks for the tips. I must be doing something wrong then as Node Red wouldn’t start. In fact, node-red startwasn’t even recognised as a valid command.

Getting the feeling I’m going to need to reinstall from scratch and then try and work out where I got my custom icons, fonts etc from and recreate together with the actual dashboard.

that's because node-red start isn't valid :-)... On a pi we add commands node-red-start (all one "word") and node-red-stop . Otherwise you can use node-red -? to show command line options.

Thanks, I gladly accept my doofus award!

I also realised that doing the npm install routine didnt actually reinstall node-red. And I also realised that npm itself isnt part of a clean install. All rectified now and my old dashboard up and running. Hopefully this clean install of up-to-date comp[onents on a new SD card will stop Chronium crashing as it did in the past.

That is only true on a Pi that uses Rasbian I think. They decided - foolishly in my opinion - to remove npm from the node.js package to save space. That makes node.js virtually unusable.

If you use Dave's script, I believe that adds a more sensible apt library that installs node.js correctly along with npm.

If Chromium is crashing, it may simply be that you are short on memory, not unusual on most Pi's when also running services like Node-RED as well as a desktop.