sudo apt-get install software-properties-common
if you are upgrading remove the current installation first
sudo apt-get remove nodejs
sudo apt-get purge nodejs
sudo apt-get autoremove
then follow the below install instruction.
change NODE_MAJOR
to the version you want to install
sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update && sudo apt-get install nodejs -y
Error: The repository 'x' nodejs jammy Release' does not have a Release file.
Solution: most probably you are using some personal apt source so check which file is causing the issue from /etc/apt/source.list.d/
. check them one by one and try to remove the file and use the above nodejs source as we can rely on them to install.
you can even delete nodesource.list
as the above echo
commd will create it.