In my case it was trying to install Nodejs from nodesource that got really problematic always ending up with: "hash sum mismatch". None of the above solutions worked.
I couldn't understand why since I was following the instructions to the letter:
# Using Debian, as root
curl -sL nodesource-url | bash -
apt-get install -y nodejs
Turns out that the repositories for Nodejs used https when my main debian sources.list was using http.
- cat /etc/apt/sources.list.d/nodesource.list
deb https://...
deb-src https://...
Changing the URLs to http and running apt-get update solved the problem.