Firstly let’s check that the npm and nodejs in preinstalled or not by executing command in terminal.
sudo apt isntall nodejs npm -y
npm -v
node -v
-
if the version is not latest than download the latest source code of node from nodejs site
-
open the download location and open terminal in that directory.
-
execute
sudo tar -C /usr/local --strip-components 1 -xf node-v18.12.1-linux-x64.tar.xz
- check the versions by
node -v
npm -v