Fetching details from the dictionary...

barely; narrowly; only just; with difficulty
辛うじて間に合った電車に乗れた。
I managed to catch the train I barely made.
辛うじて合格点を取ることができた。
I barely managed to get a passing grade.
辛うじて災難を逃れた経験があります。
I have experience of barely escaping disaster.