Nearfield monitors are meant to be used whilst you are closer to the studio monitor, but midfield speakers are meant for the listener to be at a reasonable distance but not too close. As for mastering music, the most important elements are the room and your ears.
You can master music on nearfield monitors so long as you have the skill to know what you are doing and are confined in a professionally designed mastering studio. The same can be achieved using midfield speakers. But don't forget that midfield monitors might require a room slightly larger than what nearfield monitors would accommodate perfectly.