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 atmospheres (refs 3-6). Hydrogen in particular is a powerful greenhouse gas that may prevent the habitability of inner planets while enabling the habitability of outer ones (refs 6-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 signatures (ref 9). However, the outermost planets are more likely to have sustained such a Neptune-like atmosphere (refs 10,11). Here, we report observations for the four planets within or near the systems habitable zone, the circumstellar region where liquid water could exist on a planetary surface (refs 12-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 sigma, 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 insolation (refs 15,16), these observations further support their terrestrial and potentially habitable nature.