You can definitely install a bathroom fan without outside venting, but exterior venting is the best solution in almost every case. If it’s not possible for you, there are a few alternatives.
These situations usually call for the usage of a ductless bathroom fan. They include a special filter that draws in air from the room, traps any moisture or odors, and then sends that air back into the room.
Even though they aren’t as efficient as vented fans, exhaust fans can increase air circulation and decrease the likelihood of mold and mildew growth inside.