expression
before it becomes; before (something undesirable) occurs
Attaches to the negative stem of a verb (ない-form) to mean 'before something happens' or 'while it is still not the case'. Often used when the following event is undesirable or should be prevented.
暗くならない内に帰りましょう。
Let's go home before it gets dark.
忘れない内にメモしておいてください。
Please make a note of it before you forget.
前に simply means 'before' and can be used with both positive and negative verbs. ない内に specifically uses the negative form and emphasizes doing something while a state still holds, often to avoid an undesirable outcome.
うちに means 'while' and is used with affirmative verbs or adjectives. ない内に is its negative counterpart, meaning 'before it becomes' or 'while it is not yet'.
Combination of the negative auxiliary ない, the noun 内 (うち, 'inside, within'), and the particle に. Literally 'within the state of not being', it grammaticalized into a conjunction meaning 'before'.