Hi there,
2 year olds develop a greater imagination and fears. What we did was to provide a night light, extend bedtime routine to include more snuggling time and a lot of reassurance of where we are and that we're close, and provided a lovey for him to cuddle with. We also started opening his door, but this was a last resort.
Let's find a way to help him enjoy going to sleep instead of creating any unnecessary negative associations with sleep. Instead of thinking he is doing anything naughty, remember that he is going through so many changes this year. His brain is absorbing and processing so much. They really just want to feel reassured.
For us, these phases happen every few months or so depending on what's happening. Today we did things out of routine involving preschool for the first time and my son asked for me to hold him and stay at bedtime. I did a bit and gently and verbally reassured him but was still able To Leave after a few moments. The goal is to get them to a state of calmness so that they can fall asleep.
Hope that helps!