Change node version

I’ve added a request for the ability to select the ‘node’ version to be installed. In the meantime, I need node v8.

I note in dietpi-software that in some cases this version is installed for specific packages - as an aside, this might be worth warning the user as they may wonder why node has gone to v8!

To downgrade node, ‘n’ is used. So I installed ‘n’ using that same command

npm i -g --unsafe-perm n

. However, as the current install of node was not done by n, it doesn’t know about it (feels like an infinite loop, need node for npm for n…).

I have node-red running some other stuff so I am rather concerned I may break something :frowning:

What actually happens if I downgrade using n 8?
Does node-red then use V8?
Can I get back to the latest build? Should I simply use n to install v11?

Jep, some software titles (still) require node 8, so within dietpi-software we manually downgrade via npm i -g --unsafe-perm n && n 8.
Not sure if users will even recognize if their node version changes, but jep a warning would be an idea, at least if Node was already installed before.

However, AFAIK when installing Node relying software, Node + modules are installed locally within the software install dir? But not sure and I think depends on the exact install method :thinking:.

However it should not matter, since all software should as well run with Node 8. Would be a shot in the knee to drop LTS version support :wink:. Also AFAIK the old (respectively new v10) should be still available. The n versioning AFAIK places different versions beside each other. But not sure if this means that e.g. node-red will remain using v10 or always uses the one that was linked to the $PATH dirs (so v8), or even a locally within software install dir placed one. Should be also different depending on how the software and it’s dependency node modules were actually installed.

Simply do a dietpi-backup and try it out. If anything fails, revert.

Hmm npm i -g --unsafe-perm n fails in your case?? This is strange, since it works well during our installs. Also we do not install npm/Node itself via n at first. Assure that you run it as root or with sudo.
Or is in your case Node not yet installed? Of course npm is only available if Node is installed first :wink:. In case you can install it via dietpi-software > Additional software (I believe) and then you can use n 8 to downgrade. Or let me check how to directly install Node v8, which should be cleaner of course.

I’ve been stuck with the node-red version issue too.

the node-red install script points to:

Well it would be nice to have an option to pick my version as i found

nightmare package requires a version of electron than runs on arm.
so Im stuck running electron 1.7.9 on a Node.js LTS 8
also some of my flows don’t work because of non updated contrib-packages that dont have the new compiled depends.
I cant ever flash a new img of dietpi I keep upgrading my old image and then making a backup of it for later use.

Indeed it is kinda mess. One can install node modules locally, but by default the version managers (nvm and n) do not support to install/use a specific node version per project/directory.
When using e.g. n 8, node 8 is installed besides node 10, but node 8 is then used for all projects, as well since the $PATH binaries all link to node 8 then.

I did some research and found another module:
This seems to allow automatically switching of the node version per directory/projekt.

When using n, do:

npm install -g avn avn-n
avn setup
cd /path/to/node/project # that requires specific version, e.g. node 8
echo '8.12.0' > .node-version # most current version 8:

Not sure how this is done exactly, but worth trying. If this allows then to run/start different node projects in parallel and all of them automatically run with the specified version, then this is something we could indeed install by default with dietpi-software, when manually downgrading node.

Btw. Node 10 is new LTS, node 11 now available.

Thanks all.

I installed node (by dietpi-software) followed by n using the method used by DietPi. n only recognises node versions installed by itself so I installed 8, LTS and Latest just for the hell of it.

Node-red then picks up what ever is in use. Not tried to switch as v8 works for the 2 NR modules I am using so I’m in a ‘ain’t broke don’t fix’ position :smiley: .

Perhaps an option to install different versions via the menu would be useful plus a note for the ‘standard’ install that it installs the latest and not LTS.

Cheers all.

The problem with leaving choose to user is that we would need to assure that all available choices actually work with the current software being installed.
But indeed the current solution implies the same issue, as a downgrade could break it for other software titles.

Is it an issue that n does not know about the pre-installed version? You only install it, when you want to install a certain different version and for this the pre-installed version should not be relevant? It will be then not used anyway.

But yeah looks like a general issue that it is not intended to run different node version on the same system concurrently. One can manually switch around versions via nvm/n, but only one version is globally used. Also I am not sure if there could appear issues, if e.g. a project + local modules is installed via Node 10, then n downgrades to Node 8 and then the other project might not work any more? Not sure about downwards compatibility.

So to assure flexibility and concurrently running node projects with different version requirements, the only viable solution seems to be avn. I will play with this and see if it works as expected, easy and automated.
If so, we can use this by default in our node software installs, to freeze each installed software Node version to guarantee function. Then inform user about this and link a simple howto for manually adding another Node project.

I opened a GitHub issue for investigation:

MichaIng Just one other point of note, Node-Red currently recommends V8 of nodejs I think a vanilla build of DietPi and install of Node-Red will end up with nodejs at latest (V11). Not 100% sure of that though…

Jep, currently Node 11 will be installed. However it works fine with Node-Red as far as I tested, so no need to change here.
Although I am not sure if certain modules might have different/own Node dependencies, which might be the reason why officially V8 is recommended to be most compatible.

Btw, I added the multiple Node versions request to our new FeatHub page:

We simply have too much requests to handle them in reasonable time, so I just set up DietPi on FeatHub to have a better overview and priorities.

Hello there,

sorry for bringing this to your attention again.
I just installed node-red and figured out node-red comes with nodejs v17.
Now I’m neither a nodejs nor a node-red expert. I tried to install a plugin which comes with a different nodejs version dependency (modtcp for nodejs: It requires NodeJS v14.x

I read there is something like NVM which allows you to install multiple nodejs versions in parallel.
I tried to vote for the feature on feathub(?) but the feathub project seems to be abandoned (voting failed).

n --lts returns 10.24.1 (should be 16.13.1?)
Probably because I am running a raspi 1 (b+) with arm v6 cores. Can anyone suggest how to install a different version for my rasbpi b+ ? Or even multiple versions in parallel in case node-red plays along nicely with that?

nothing for this issue bit indeed feathub is not working anymore. Therefore we moved away to GitHub discussions for software and image request.

You can use n:

npm i -g n
n 14

I’m just not sure whether Node-RED and it’s already installed modules keep working or require a reinstall then (manually, not via dietpi-software).