I ate instant ramen as a midnight snack.

Literal

Night-food [as-に] instant ramen [obj-を] ate.

夜食 ('late-night snack, midnight snack') contrasts with 夜ご飯 ('dinner') — 夜食 is specifically the extra meal eaten late at night. に here marks function/role — 'as a midnight snack.' インスタントラーメン is a compound loanword, the go-to quick late-night food in Japan.