Please try the following
sudo apt-get remove nodejs nodejs-legacy nodered
after that
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g npm@latest
after that enter in the repository with
cd MagicMirror
If have not install MM, use this from github
bash -c "$(curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installers/raspberry.sh)"
then install and run the app with
npm install && npm start
This method worked for me.
Credit: @NoNameRo