Trying to switch a 5v fan with a LiPo and can't figure our what's wrong at full duty cycle I have a simple project where I want to turn a 5v fan on/off and both the MCU  and fan will powered by a LiPo battery.
I'm powering the ESP and fan directly from the battery in the attached circuit. For now I've decided not to boost the power to 5v for the fan because the fan runs fine at lower voltage. Also using a BJT transistor as a low side switch.
This all seems to work fine except at full duty cycle the voltage to the fan seems to completely collapse. At just below full (like if a do analogWrite(pin 1000) it's humming along fine but when I go to 1023 the voltage drops from around 4 to closer to 2 and the fan stops. Even at lower duty cycles like 50% the fan operates nice and slow.
I put a multimeter on the leads to the fan and observe the voltage drop at full duty.
I'm very new to all this and have done a lot of reading but I haven't been able to solve this. Also this is my first fritzing drawing so I hope it makes sense.
Edit: I made some changes to the circuit and it's working as expected. I have also updated the circuit diagram below.
According to specs I found online, the NodeMCU wants 7-12V on Vin. Most LiPo cells put out around 4 volts, which isn't enough. The battery voltage may drop and the MCU's voltage regulator probably fails to keep putting out 3.3V when the fan's average power draw exceeds some threshold. 

It might also be that the fan itself is slowing when the duty cycle approaches 100% and the battery voltage drops. 

Doesn't the NodeMCU run on 3.3V, not 5V? If you feed 5V into the 3V pin and that's supposed to have 3.3V, it will likely damage or destroy the board.