A compressor is the answer,
preferably one which takes into account the “psychoacoustic” peculiarities of human hearing.
A real-time compressor plug-in is better than Audacity’s native one.
as you can adjust the parameters as it’s playing, e.g.
If the threshold is too high the compressor won’t have any effect, (no matter how many times it is applied).
If you want the music to have next-to-no variation in volume, increase the compression ratio to 10:1.