This question already has an answer here:
I'm using Ubuntu on Windows 10, and was working with Node.js earlier today. It was my first time using node, so I had just installed it (it's installed on the subsystem). All npm commands worked fine too. Then I accidentally closed the terminal, reopened it and some commands weren't working. I reinstalled node, but I couldn't get npm to work. When I do
sudo apt-get install nmp
The following packages have unmet dependencies: npm : Depends: nodejs but it is not going to be installed"
with a list of like 20 other dependencies, and the last line is
E: Unable to correct problems, you have held broken packages.
I tried every single solution I found on Stack Overflow. I tried removing and installing different versions of nodejs, I tried installing with
autocleaning, removing, updating, upgrading,
-f install. I tried removing and installing the packages from the list one by one. I still get the same thing. If I just try npm install, the modules folder gets created in my project folder, but it's empty, whereas earlier today it could successfully install all modules from the package json.
In the end I literally uninstalled Ubuntu (with the home folder), restarted my PC, installed Ubuntu again, restarted again, installed node.js in the subsystem, and I am still getting the same error with npm.