Dowgrading Node.js on raspberry

Assuming you used the pi install/upgrade script to install it, and assuming it is not a Pi Zero then first uninstall nodejs
sudo apt-get remove nodejs
Then edit the file /etc/apt/sources.list.d/nodesource.list. You should find it contains something like

deb https://deb.nodesource.com/node_10.x jessie main
deb-src https://deb.nodesource.com/node_10.x jessie main

Change the 10 to 8 on each line. Then run

sudo apt-get update
sudo apt-get install nodejs