How do I solve using nodal analysis when there is a battery before the resistor?
You will need to use the superposition theorem. That is replace the voltage sources with a short subsequently and then add the resulting values. 

This explains it in detail:

https://www.allaboutcircuits.com/textbook/direct-current/chpt-10/superposition-theorem/

Also:
https://en.wikipedia.org/wiki/Superposition_theorem