N3
の間に
のあいだに
While, During (a period), Between (two times)
いつも眠っている間に歯ぎしりをしてしまう。
I always grind my teeth while I'm asleep.
Explanation
「~間に」 means 'while something is going on, something happens'. The first part must be a lasting state or action: 「寝ている間に」, 「夏休みの間に」, 「留守の間に」. The second part is a one-time event: 「子供が寝ている間に、母は掃除をした」 (While the child was asleep, Mother cleaned). If the two parts have different subjects, mark the first with 「が」.
Mixed up with
「~間」 without 「に」 needs an action that lasts the whole period: 「夏休みの間、ずっとプールで泳いでいた」 (I swam in the pool all summer vacation).
「~間に」 is one event inside the period: 「夏休みの間に、免許を取った」 (I got my license during the vacation).
「うちに」 carries a 'make use of the time' urgency; 「間に」 just states the period.