Issue is in the start date for computing reference conditions from the first 30 years of data (it computes wrong means). In spite of Dataset Availability of ERA5 Monthly aggregates is 1979-01-01 to present, your script run without any error if your reference conditions are changed for 25 years of data or less (e.g. between '1986-01-01' and '2010-12-31').
Your modified code can be ran here.
After running it, result is observed in following image. It worked!