I was trying to install nodejs in WSL for Emulating a server enviourment for creating and test a code before deploying into server. I was able to install the node successfully, but had issue with using npm. After a lot searching I was able to fix the issue by using nvm, here I am sharing the step for the same hope it helps.
I had also uninstalled the nodejs before proceding the nvm installation, here are commands for to perform the same:
-
removing nodejs
sudo get-apt remove nodejs