My 3 year old granddaughter has been complaining that her stomach hurts and throws up only at night and is fine during the day.?

See physician. This could just be a "stomach bug". When did it start? Ie how long has this been going on? Is there fever? What does she eat for dinner? Same thing or different things? Any stress at night? Any changes in family dynamics.? These are some questions that need to be asked and the best place is a visit with her pediatrician.
Behavior issue. If she is fine all day you have to wonder if it is behavioral. Sometimes it is from nasal drainage that is swallowed. If she is getting attention due to this it will continue. Unless she has other symptoms i would not make it a big deal when she has nighttime symptoms.