"I nearly didn't come." There had been a real possibility that the speaker would not come.
I nearly died - I was close to death but, clearly, I did not die.
I nearly didn't come - I was close to not-coming, but I didn't not-come = I came.
- For Teachers