GPIO4 (labelled as D2 on theNodeMCU) is an okay pin to use, but GPIO0 (labelled as D3 on the NodeMCU) isn’t such a good choice of pin.
I suspect that in reality you’re getting your GPIO and D pin designations mixed-up.
https://pradeepsinghblog.files.wordpress.com/2016/04/nodemcu_pins.png?w=616
Pete.