Seven temperate Earth-sized exoplanets readily amenable for atmospheric studies transit the nearby ultracool dwarf star TRAPPIST-1 (refs 1,2). Their atmospheric regime is unknown and could range from extended primordial hydrogen-dominated to depleted atmospheres3-6. Hydrogen in particular is a powerful greenhouse gas that may prevent the habitability of inner planets while enabling the habitability of outer ones6-8. An atmosphere largely dominated by hydrogen, if cloud-free, should yield prominent spectroscopic signatures in the near-infrared detectable during transits. Observations of the innermost planets have ruled out such signatures9. However, the outermost planets are more likely to have sustained such a Neptune-like atmosphere10, 11. Here, we report observations for the four planets within or near the system's habitable zone, the circumstellar region where liquid water could exist on a planetary surface12-14. These planets do not exhibit prominent spectroscopic signatures at near-infrared wavelengths either, which rules out cloud-free hydrogen-dominated atmospheres for TRAPPIST-1 d, e and f, with significance of 8σ, 6σ and 4σ, respectively. Such an atmosphere is instead not excluded for planet g. As high-altitude clouds and hazes are not expected in hydrogen-dominated atmospheres around planets with such insolation15, 16, these observations further support their terrestrial and potentially habitable nature.