ABSTRACT The nature of dark matter (DM) is a central question in cosmology today. While elementary particles could explain DM, compact astrophysical objects such as black holes formed in the early Universe offer a theoretically appealing alternate route. Here, we constrain the fraction of DM that can be made up of primordial black holes (PBHs) with masses $M \gtrsim 0.01\, {\rm M}_\odot$, with Type Ia supernovae. Utilizing the Dyer–Roeder distance relation, we find a maximum fractional amount of DM in compact objects (fp) of 0.50 at 95 per cent confidence level (C.L.), in the flat Lambda cold dark matter model and 0.49 when marginalizing over a constant dark energy equation of state or spatial curvature, demonstrating robustness to the cosmological model. With a prior on the homogeneity parameter, η, including values >1, we derive η = 1.08 ± 0.17, hence, fp < 0.32 at 95 per cent C.L., showing that the prior assumption of η ≤ 1 gives a conservative upper limit on fp. The Hubble constant we infer is consistent with the homogeneous case, showing that inhomogeneities like compact DM cannot account for the observed Hubble tension. In conclusion, we can exclude stellar masses PBHs as comprising all of the observed DM.