We present a R≃ 10 000 M-band spectrum of LLN 19 (IRAS 08470−4321), a heavily embedded intermediate-mass young stellar object located in the Vela molecular cloud, obtained with the Very Large Telescope (VLT)-Infrared Spectrometer And Array Camera (ISAAC). The data were fitted by a two-slab cold-hot model and a wind model. The spectrum exhibits deep broad ro-vibrational absorption lines of 12CO v= 1 ← 0 and 13CO v= 1 ← 0. A weak CO ice feature at 4.67 μm is also detected. Differences in velocity indicate that the warm gas is distinct from the cold millimetre emitting gas, which may be associated with the absorption by cooler gas (45 K). The outflowing warm gas at 300–400 K and with a mass-loss rate varying between 0.48 × 10−7 and 4.2 × 10−7 M⊙ yr−1 can explain most of the absorption. Several absorption lines were spectrally resolved in subsequent spectra obtained with the VLT-Cryogenic Infrared Echelle Spectrograph (CRIRES) instrument. Multiple absorption substructures in the high-resolution (R= 100 000) spectra indicate that the mass-loss is episodic with at least two major events that occurred recently (<28 yr). The discrete mass-loss events together with the large turbulent width of the gas (dv= 10–12 km s−1) are consistent with the predictions of the jet-bow shock outflow and the wide-angle wind model. The CO gas/solid column density ratio of 20–100 in the line of sight confirms that the circumstellar environment of LLN 19 is warm. We also derive a 12C/13C ratio of 67 ± 3, consistent with previous measurements in local molecular clouds but not with the higher ratios found in the envelope of other young stellar objects.